Commit graph

55 commits

Author SHA1 Message Date
Stean
c52cdb10c8 Add undocumented option -s to usage listing 2018-11-04 21:22:46 +01:00
Romuald Conty
33ce39ff71 nfc-relay-picc: fix wrong open mode for file descriptor
Fixes #280
2015-04-30 14:33:59 +02:00
Philippe Teuwen
cedbefb880 nfc-relay-picc: sleep() expects unsigned int
This avoids Coverity being unhappy that only lower bound was defined, well I hope

lower_bounds: Checking lower bounds of signed scalar "waiting_time" by "waiting_time > 0".
CID 1090343 (#1 of 1): Untrusted value as argument (TAINTED_SCALAR)
  tainted_data: Passing tainted variable "waiting_time" to a tainted sink.
  sleep(waiting_time);
2013-09-22 03:00:58 +02:00
Ludovic Rousseau
107b4ece8b Fix use after free bug
nfc_exit(context); was called 2 times

CID 1090348 (#1 of 1): Use after free (USE_AFTER_FREE)53. deref_arg:
Calling "nfc_exit(nfc_context *)" dereferences freed pointer "context".
(The dereference is assumed on the basis of the 'nonnull' parameter
attribute.)
2013-09-19 20:38:56 +02:00
Philippe Teuwen
bb5b712a74 Adding link to AUTHORS in the copyright headers 2013-07-17 13:57:56 +02:00
Philippe Teuwen
bf164220ee Unify copyright notices & update authors lists 2013-03-10 16:15:23 +01:00
Alex Lian
7b917f9a8b Windows: Clean up all compiler warnings and link warnings
- Fixed the suppression of the auto-fixup for linking against MS built libs
- Fixed all the formatting warnings by shifting to inttypes.h specifiers
- shifted to %lu for DWORD printf
2013-03-07 09:37:36 +01:00
Alex Lian
c72846e3c6 Convert by value passing of nfc_target to pointer for str_nfc_target and nfc_initiator_target_is_present
This becomes more consistent with all other pass by pointer of most structures.
Additionally, this should lessen stack memory usage, as building strings with str_nfc_target would push the target (283 bytes) plus then a copy of the info objects (up to 275) onto the stack as it dives into the sprintf functions.

Lastly, this makes my attempt at a .NET wrapper easier, as I can make passing by pointer work, but passing by value seems to bomb on the interop right now.
2013-03-07 09:16:33 +01:00
Philippe Teuwen
1d5f9956fb Fix cppcheck warning "buffer may not be null-terminated after call to strncpy()" 2013-03-06 12:38:59 +01:00
Philippe Teuwen
d577fda412 Fix cppcheck warning "scanf without field width limits can crash with huge input data"
Fix following warnings:
[examples/pn53x-tamashell.c:162]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/acr122_pcsc.c:261]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/acr122s.c:441]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/arygon.c:210]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/arygon.c:522]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/pn532_uart.c:187]: (warning) scanf without field width limits can crash with huge input data
[utils/nfc-relay-picc.c:176]: (warning) scanf without field width limits can crash with huge input data
2013-03-06 00:52:08 +01:00
Philippe Teuwen
3f5a3fd58f nfc-read-forum-tag3 & nfc-relay-picc: remove unused variable
Fix cppcheck warnings
[utils/nfc-read-forum-tag3.c:281]: (style) Variable 'len' is assigned a value that is never used
[utils/nfc-relay-picc.c:392]: (style) Variable 'res' is assigned a value that is never used
2013-03-06 00:30:38 +01:00
Philippe Teuwen
73b5c9d0af nfc_init() return rather than exit on malloc error, examples fixed accordingly 2013-03-05 22:24:59 +01:00
Philippe Teuwen
bece73faaf Error conditions in utils & examples: fix leaks, unify style (see details)
* in main():
** errx()/err()/return -> exit()
** return values -> EXIT_SUCCESS & EXIT_FAILURE

* out of main:
** err()/errx()/exit() -> return
** change retval from size_t to int to allow returning errors
** don't use EXIT_SUCCESS / EXIT_FAILURE as retvals

* add nfc_close() & nfc_exit() to exit() on errors
* add missing fclose() on errors
* add missing test if (pnd == NULL)
* unify style if (pnd == / != NULL)
* remove goto's
* few related fixes
* remove if(pnd!=NULL) test on nfc_close() calls
2013-03-05 19:44:59 +01:00
Philippe Teuwen
4d0ee443d1 Fix crash in nfc-relay-picc -i/-t if fd3 or fd4 is missing 2013-02-01 21:55:29 +01:00
Philippe Teuwen
386e08d8b3 Fix nfc_initiator_select_passive_target() in several utils if tag is missing 2013-02-01 20:52:49 +01:00
Philippe Teuwen
5876e33e49 Fix returned value ((res=f()<0)) => ((res=f())<0); this solves a bug in nfc-relay-picc 2013-01-22 00:56:34 +01:00
Philippe Teuwen
0ac3b26982 nfc-relay-picc: Fix received bytes count 2013-01-22 00:54:47 +01:00
Romuald Conty
5b0e276572 Examples and utils are now updated to use the requiered nfc_context 2012-12-05 00:51:13 +01:00
Philippe Teuwen
6c7c0a6e63 ReadMobib: make it compatible with Basic card 2012-11-10 17:11:48 +01:00
Romuald Conty
9afa3c6598 Use copyright format recommended by GNU project.
http://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html
2012-10-21 14:09:16 +00:00
Romuald Conty
310d7eba07 New str_nfc_target() function in API.
This allow to convert a nfc_target struct into allocated string.
2012-09-17 13:47:54 +00:00
Philippe Teuwen
568317929d astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper --unpad-paren --pad-header --align-pointer=name 2012-05-29 15:55:35 +00:00
Philippe Teuwen
01303fab0d astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper --unpad-paren --pad-header 2012-05-29 15:54:36 +00:00
Philippe Teuwen
562205cc14 astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux --pad-oper 2012-05-29 15:54:00 +00:00
Philippe Teuwen
67522bae65 astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 --brackets=linux 2012-05-29 15:53:43 +00:00
Philippe Teuwen
a2cd236441 astyle --formatted --mode=c --indent=spaces=2 --indent-switches --indent-preprocessor --keep-one-line-blocks --max-instatement-indent=60 2012-05-29 15:52:51 +00:00
Romuald Conty
26865bbc19 Remove extra whitespaces/tabs before EOL.
find . -name '*.[ch]' | xargs perl -pi -e 's/\t+$//; s/ +$//'

Thanks to Ludovic.
2012-05-29 00:33:22 +00:00
Romuald Conty
2c9275adde nfc_initiator_transceive_bytes() now take a constant size for Rx buffer to have a cleaner API: no more in/out parameters 2012-05-27 21:06:22 +00:00
Romain Tartiere
e9b2f5729c Fix a bunch of warnings. 2012-05-14 13:47:31 +00:00
Ludovic Rousseau
b5e688e74a Fix compiler warnings:
nfc-relay-picc.c:76: warning: no previous prototype for ‘intr_hdlr’
nfc-relay-picc.c:85: warning: no previous prototype for ‘print_usage’
nfc-relay-picc.c:96: warning: no previous prototype for ‘print_hex_fd4’
nfc-relay-picc.c:118: warning: no previous prototype for ‘scan_hex_fd3’
nfc-relay-picc.c: In function ‘main’:
nfc-relay-picc.c:190: warning: function declaration isn’t a prototype
2012-05-13 12:53:34 +00:00
Audrey Diacre
5a475cf074 add some whitespaces 2012-01-20 09:17:38 +00:00
Audrey Diacre
4c011279ff add context to nfc_init(), nfc_exit(), nfc_open() and nfc_list_devices() functions. 2012-01-18 16:22:06 +00:00
Audrey Diacre
207199dc34 examples, test and utils use now nfc_exit() function. 2012-01-18 11:36:18 +00:00
Audrey Diacre
1d55b6f8c6 examples, test and utils use now nfc_init() function. 2012-01-18 11:09:01 +00:00
Audrey Diacre
324af418db rename nfc_connect() function to nfc_open(). 2012-01-17 15:21:56 +00:00
Audrey Diacre
9eb37b3eee rename nfc_disconnect() function to nfc_close(). 2012-01-17 14:52:39 +00:00
Audrey Diacre
1ec504e163 nfc_list_devices() function returns now the number of devices found. 2012-01-10 10:35:36 +00:00
Audrey Diacre
00818e048c rx buffer size parameter of nfc_target_init() function is now a const size_t. 2012-01-09 11:26:57 +00:00
Romuald Conty
22bea8d99b nfc_target_receive_*() need to know rx buffer size 2012-01-05 21:35:02 +00:00
Audrey Diacre
601105ef79 fix bad cast done in last revision. 2012-01-05 17:03:38 +00:00
Audrey Diacre
642f9a38f7 nfc_target_receive_bytes() function does not now use pszRx as parameter because this function returns it. 2012-01-05 16:33:55 +00:00
Audrey Diacre
239fd750c4 add timeout on nfc_target_init() and this function returns now received bytes count on success. 2012-01-05 15:10:11 +00:00
Audrey Diacre
9c1371dcca nfc_target_send_bytes() function returns now sent bytes count on success and libnfc error code on failure. 2011-12-22 15:59:08 +00:00
Audrey Diacre
ac6f652368 nfc_target_receive_bytes() function returns now received bytes count on success and libnfc error code on failure. 2011-12-22 15:39:51 +00:00
Audrey Diacre
c41d7de8ca nfc_initiator_select_dep_target() function returns nox libnf error code and fix some uses of nfc_initiator_transceive_bytes() function. 2011-12-21 09:15:44 +00:00
Audrey Diacre
103485518c nfc_initiator_select_passive_target() function returns now libnfc error code. 2011-12-19 16:27:50 +00:00
Audrey Diacre
ba2a7cfe2e nfc_target_init() function returns now 0 on succes and libnfc error code on failure. 2011-12-19 15:35:37 +00:00
Romuald Conty
bf7c36d9bb less structs and defines publicly exposed
- nfc_device is now an opaque type;
 - PN53x specific errors are not public anymore;
 - nfc_device_name() renamed to nfc_device_get_name() for the sake of consistency;
 - examples/*, utils/* uses the new nfc_device_get_name() function instead of access directly to struct's content;
 - new error defined: NFC_ERFTRANS for notifying about RF transmission error, its used by mifare.c to detect permissions error on mifare;
 - drivers initiator_transceive_bytes() function now returns libnfc's error code on failure (<0), and received bytes count on success (>=0);
 - remove some unused errors.
2011-12-19 00:23:21 +00:00
Audrey Diacre
98355d36a7 nfc_initiator_init returns now error code and nfc_initiator_list_passive_targets returns now the number of targets found or error code. 2011-12-15 11:46:14 +00:00
Audrey Diacre
52bc5853d8 Remove whitespace after star symbol for pointers 2011-11-25 15:21:10 +00:00