mirror of
https://github.com/nfc-tools/libnfc.git
synced 2026-04-11 09:06:17 +00:00
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
This commit is contained in:
@@ -258,7 +258,7 @@ acr122_pcsc_open(const nfc_context *context, const nfc_connstring connstring)
|
||||
if (strlen(ndd.pcsc_device_name) < 5) { // We can assume it's a reader ID as pcsc_name always ends with "NN NN"
|
||||
// Device was not specified, only ID, retrieve it
|
||||
size_t index;
|
||||
if (sscanf(ndd.pcsc_device_name, "%lu", &index) != 1)
|
||||
if (sscanf(ndd.pcsc_device_name, "%4lu", &index) != 1)
|
||||
return NULL;
|
||||
nfc_connstring *ncs = malloc(sizeof(nfc_connstring) * (index + 1));
|
||||
if (!ncs) {
|
||||
|
||||
Reference in New Issue
Block a user