Commit graph

360 commits

Author SHA1 Message Date
Philippe Teuwen
1f5e14f862 cppcheck on pn53x.c: Array 'apttTargetTypes' is filled incompletely 2014-02-07 01:29:42 +01:00
Philippe Teuwen
1e4fe3bd27 nfc_initiator_target_is_present(): Support B2 ST SRx 2014-02-07 01:11:19 +01:00
Philippe Teuwen
9fd11d331b nfc_initiator_target_is_present(): Support B2 ASK CT 2014-02-07 00:53:35 +01:00
Philippe Teuwen
a3a7111210 nfc_initiator_target_is_present(): Support B' 2014-02-07 00:31:31 +01:00
Philippe Teuwen
7254e1b2ea nfc_initiator_target_is_present(): Support Jewel 2014-02-03 00:24:23 +01:00
Philippe Teuwen
827d9792dd Save & restore NP_INFINITE_SELECT status when changing it internally 2014-02-01 02:45:17 +01:00
Philippe Teuwen
69c4d0768a nfc_initiator_select_passive_target(): grant NP_INFINITE_SELECT also for ISO14443B* 2014-02-01 02:45:17 +01:00
Philippe Teuwen
510228b6e0 nfc_initiator_select_passive_target(): save current target info even if pnt=NULL 2014-02-01 02:45:16 +01:00
Philippe Teuwen
e11c5254af nfc_initiator_select_passive_target(): save current target info also for ISO14443B* 2014-01-31 23:53:29 +01:00
Philippe Teuwen
81e1dd715d nfc_initiator_target_is_present(): Fix error type in case no target is selected yet 2014-01-31 23:19:04 +01:00
Philippe Teuwen
71eda315c7 nfc_initiator_target_is_present(): Fix MFC support on PN532 2014-01-31 22:33:05 +01:00
Philippe Teuwen
7d41ed34a3 *_is_present(): more robust detection of tag gone 2014-01-30 18:30:45 +01:00
Philippe Teuwen
9a84bb0ba0 Split pn53x_initiator_target_is_present() for readability 2014-01-30 18:10:30 +01:00
Philippe Teuwen
62e78ab582 nfc_initiator_target_is_present(): support -4B on PN532 2014-01-30 12:55:51 +01:00
Philippe Teuwen
d6330a55d0 nfc_initiator_target_is_present(): better error handling 2014-01-30 11:37:37 +01:00
Philippe Teuwen
05579fde09 nfc_initiator_target_is_present(): better Felica support 2014-01-30 11:19:02 +01:00
Romuald Conty
5fe3fbdb5d Fix nfc_target_is_present() when removing a ISO14443-4A target from a PN532-based device 2014-01-30 11:10:18 +01:00
Philippe Teuwen
d893e4398c nfc_initiator_target_is_present(): fix ISO14443B-4 support 2014-01-30 00:32:21 +01:00
Philippe Teuwen
ade71ee8a6 nfc_initiator_target_is_present(): reuse iso14443_cascade_uid() 2014-01-30 00:24:06 +01:00
Philippe Teuwen
095f945224 nfc_initiator_target_is_present(): improve MFC support for 7-byte UID 2014-01-30 00:09:03 +01:00
Philippe Teuwen
9d63a93dd8 nfc_initiator_target_is_present(): improve MFC support
Increase timeout to support Tikitag & PN533
Fix support for MFC Mini on PN533
2014-01-29 23:30:50 +01:00
Philippe Teuwen
94f4e001f4 nfc_initiator_target_is_present(): support MFUL on PN532 too 2014-01-29 23:02:36 +01:00
Romuald Conty
7b5ab23452 Partial MFC support while checking target presence on PN532/PN531
Goal is to implement "ping" on MFC the same as PN533 does. This patch implements MFC re-selection, but do not take care about authentication; this means this will have side effect while you are authenticated on a MFC block.
2014-01-29 11:36:12 +01:00
Philippe Teuwen
1a3acdadc4 Prepare nfc_initiator_target_is_present() to support more cases
and return NFC_EDEVNOTSUPP for cases not yet supported, depending on the chipset.

Little helper to debug future additions to that function:

// LIBNFC_LOG_LEVEL=193 ./nfc-testing
int
main(void)
{
  nfc_device *pnd;
  nfc_modulation nm = {  .nmt = NMT_ISO14443A,  .nbr = NBR_106,  };
  nfc_context *context;
  nfc_init(&context);
  pnd = nfc_open(context, NULL);
  nfc_initiator_init(pnd);
  nfc_target nt;
  nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt);
  while (nfc_initiator_target_is_present(pnd, NULL) == NFC_SUCCESS);
  nfc_close(pnd);
  nfc_exit(context);
}
2014-01-29 01:54:46 +01:00
Philippe Teuwen
65ad186109 make style 2014-01-28 13:09:33 +01:00
Romuald Conty
e5c732e181 Fix internal current target when using nfc_initiator_poll_target() (Thanks to Bjoern Kinscher)
Fixes Issue 265.
2014-01-28 10:45:05 +01:00
Romuald Conty
b7f590acc8 Set correctly last_error when running pn53x_initiator_target_is_present() 2014-01-28 10:40:18 +01:00
Romuald Conty
9a0a10826b Fix pn53x_initiator_target_is_present() when saved target is NULL
This patch prevents from running any command to check target presence when none have been saved
2014-01-28 10:27:10 +01:00
Philippe Teuwen
d47623319d nfc_initiator_target_is_present() allows pnt==NULL 2014-01-27 16:07:24 +01:00
Romuald Conty
a7fc1bddaf Fix nfc_target_init() timeout return
This patch prevent from returning a successfull error code while timeout occurred.

Thanks to blck on forum:
http://www.libnfc.org/community/post/4913/#p4913
2013-12-06 16:03:00 +01:00
Philippe Teuwen
4a91859150 Fix unharmful warning
Commit 54729fb458 removed some dead code spotted by Coverity
but it had as effect to trigger a gcc warning, which prefers to see all enum in a switch rather than dead code:

pn53x.c: In function 'pn53x_InJumpForDEP':
pn53x.c:2552:5: warning: enumeration value 'NBR_UNDEFINED' not handled in switch [-Wswitch]
pn53x.c:2552:5: warning: enumeration value 'NBR_847' not handled in switch [-Wswitch]

So both switches were merged, which slightly optimizes the code for speed.
2013-09-22 12:02:31 +02:00
Philippe Teuwen
7cb8fd3833 verify return of pn53x_set_property_bool()
Problem reported by Coverity:
CID 1090321 (#1 of 1): Unchecked return value (CHECKED_RETURN)
  unchecked_value: No check of the return value of "pn53x_set_property_bool(pnd, NP_INFINITE_SELECT, true)".
2013-09-22 03:36:45 +02:00
Philippe Teuwen
90160d6507 Fix possible overflow
Note that this could happen e.g. if a fake PN533 sends malicious frames over USB

CID 1090329 (#1 of 1): Overflowed return value (INTEGER_OVERFLOW)
  overflow_sink: Overflowed or truncated value (or a value computed from an overflowed or truncated value) "res" used as return value.
2013-09-22 03:26:33 +02:00
Philippe Teuwen
54729fb458 Remove dead code
Problem reported by Coverity:
  dead_error_condition: The switch value "nbr" cannot be "NBR_UNDEFINED".
  CID 1090326 (#1 of 2): Logically dead code (DEADCODE)
  dead_error_begin: Execution cannot reach this statement "case NBR_UNDEFINED:".
2013-09-22 03:09:08 +02:00
Philippe Teuwen
ddf58f2d69 Changing conditions to avoid Coverity to complain in artificial situations
CID 1090331 (#1 of 1): Out-of-bounds access (OVERRUN)
11. overrun-buffer-arg: Overrunning array "pnti->nai.abtUid" of 10 bytes by passing it to a function which accesses it at byte offset 11 using argument "pnti->nai.szUidLen" (which evaluates to 12).
2013-09-20 00:13:21 +02:00
Philippe Teuwen
a5e7dec797 Initialize array to keep Coverity happy
as Coverity fails seeing that szTargetTypes will always be = 0 in the case believed to lead to reading unitialized data in apttTargetTypes.

CID 1090347 (#1 of 1): Uninitialized scalar variable (UNINIT)
4. uninit_use_in_call: Using uninitialized element of array "apttTargetTypes" when calling "pn53x_InAutoPoll(struct nfc_device *, pn53x_target_type const *, size_t const, uint8_t const, uint8_t const, nfc_target *, int const)".
2013-09-20 00:01:41 +02:00
Philippe Teuwen
3e7dab1e8d Fix buffer overflow and fix triple-size UID reported by PN531
A buffer overflow could occur is a triple-size UID card was read with a PN531.
Moreover the way cascade tags were removed was just wrong.

Problem reported by Coverity
CID 1090331 (#1 of 1): Out-of-bounds access (OVERRUN)
10. overrun-buffer-arg: Overrunning buffer pointed to by "&pnti->nai.abtUid[5]" of 10 bytes by passing it to a function which accesses it at byte offset 11 using argument "7UL".

Coverity reported a read out of bounds but actually the real problem if PN531 and triple-size UID will already occur at
    memcpy(pnti->nai.abtUid, pbtRawData, pnti->nai.szUidLen); where abtUid is of size 10 and szUidLen of size 12
2013-09-19 22:57:15 +02:00
Ludovic Rousseau
967f6e5623 Remove dead code
The switch case has a default rule and a return in every cases. So the
code after the switch will never be executed.

Problem reported by thei Coverity tool
CID 1090408 (#1 of 1): Structurally dead code (UNREACHABLE)unreachable:
This code cannot be reached: "if (pn53x_current_target_ne...".
2013-09-19 20:34:58 +02:00
Peter Meerwald
40672ed62b pn532: fix typo in comment
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-09-03 16:31:25 +02:00
Peter Meerwald
0b9fe52b2b pn53x: fix logging, timeout value
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-09-03 16:30:01 +02:00
Philippe Teuwen
8fe13ece62 pn53x_initiator_transceive_bytes_timed(): use proper CRC_B if TypeB 2013-08-19 15:47:44 +02:00
Philippe Teuwen
bb5b712a74 Adding link to AUTHORS in the copyright headers 2013-07-17 13:57:56 +02:00
Philippe Teuwen
2db4a0e7e4 make style
new version of astyle, better separation of XOR
2013-07-03 00:16:15 +02:00
Philippe Teuwen
5cda3af5d4 Fix warnings Null pointer passed as an argument to a nonnull parameter
acr122s.c:331:3: warning: Null pointer passed as an argument to a 'nonnull' parameter
  memcpy(buf, data, data_size);
  ^           ~~~~

pn53x.c:3138:3: warning: Null pointer passed as an argument to a 'nonnull' parameter
  memcpy(CHIP_DATA(pnd)->current_target, pnt, sizeof(nfc_target));
  ^                                      ~~~
2013-07-02 23:47:45 +02:00
Philippe Teuwen
cc7c0c32f1 Fix warning about incompatible types
pn53x.c:85:57: warning: Result of 'malloc' is converted to a pointer of type 'nfc_modulation_type', which is incompatible with sizeof operand type 'nfc_modulation'
    CHIP_DATA(pnd)->supported_modulation_as_initiator = malloc(sizeof(nfc_modulation) * 9);
                                                        ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
2013-07-02 22:44:55 +02:00
Romuald Conty
936210c076 pn53x: only create a current target when at least one have been found. 2013-05-13 09:43:46 +02:00
Philippe Teuwen
41ec6d49f6 Add ISO14443-4 chaining support for RX (MI) 2013-04-28 23:52:15 +02:00
Philippe Teuwen
890f028b0c pn53x_current_target_new() now returns null ptr upon malloc() error 2013-03-18 01:00:41 +01:00
Philippe Teuwen
69c435f348 fix missing tests on malloc() return 2013-03-18 00:46:31 +01:00
Philippe Teuwen
06d5b54308 pn53x_data_new() now returns null ptr upon malloc() error 2013-03-18 00:21:08 +01:00