diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index eac9993..42a06ff 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -159,7 +159,7 @@ int main(int argc, const char *argv[]) while (isspace(cmd[offset])) { offset++; } - sscanf(cmd + offset, "%d", &s); + sscanf(cmd + offset, "%10d", &s); printf("Pause for %i msecs\n", s); if (s > 0) { sleep(s * SUSP_TIME); diff --git a/libnfc/drivers/acr122_pcsc.c b/libnfc/drivers/acr122_pcsc.c index e24e425..6a9151a 100644 --- a/libnfc/drivers/acr122_pcsc.c +++ b/libnfc/drivers/acr122_pcsc.c @@ -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) { diff --git a/libnfc/drivers/acr122s.c b/libnfc/drivers/acr122s.c index 0b19d32..c84a8da 100644 --- a/libnfc/drivers/acr122s.c +++ b/libnfc/drivers/acr122s.c @@ -438,7 +438,7 @@ acr122s_connstring_decode(const nfc_connstring connstring, struct acr122s_descri return 2; } unsigned long speed; - if (sscanf(speed_s, "%lu", &speed) != 1) { + if (sscanf(speed_s, "%10lu", &speed) != 1) { // speed_s is not a number free(cs); return 2; diff --git a/libnfc/drivers/arygon.c b/libnfc/drivers/arygon.c index a788807..315fc0b 100644 --- a/libnfc/drivers/arygon.c +++ b/libnfc/drivers/arygon.c @@ -207,7 +207,7 @@ arygon_connstring_decode(const nfc_connstring connstring, struct arygon_descript return 2; } unsigned long speed; - if (sscanf(speed_s, "%lu", &speed) != 1) { + if (sscanf(speed_s, "%10lu", &speed) != 1) { // speed_s is not a number free(cs); return 2; @@ -519,7 +519,9 @@ arygon_firmware(nfc_device *pnd, char *str) if (0 == memcmp(abtRx, arygon_error_none, 6)) { uint8_t *p = abtRx + 6; unsigned int szData; - sscanf((const char *)p, "%02x%s", &szData, p); + sscanf((const char *)p, "%02x%9s", &szData, p); + if (szData > 9) + szData = 9; memcpy(str, p, szData); *(str + szData) = '\0'; } diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index f7b8867..4ae4380 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -184,7 +184,7 @@ pn532_connstring_decode(const nfc_connstring connstring, struct pn532_uart_descr return 2; } unsigned long speed; - if (sscanf(speed_s, "%lu", &speed) != 1) { + if (sscanf(speed_s, "%10lu", &speed) != 1) { // speed_s is not a number free(cs); return 2; diff --git a/utils/nfc-relay-picc.c b/utils/nfc-relay-picc.c index 1659c4d..43988e5 100644 --- a/utils/nfc-relay-picc.c +++ b/utils/nfc-relay-picc.c @@ -173,7 +173,7 @@ main(int argc, char *argv[]) printf("INFO: %s\n", "Swapping devices."); swap_devices = true; } else if (0 == strcmp(argv[arg], "-n")) { - if (++arg == argc || (sscanf(argv[arg], "%i", &waiting_time) < 1)) { + if (++arg == argc || (sscanf(argv[arg], "%10i", &waiting_time) < 1)) { ERR("Missing or wrong waiting time value: %s.", argv[arg]); print_usage(argv); exit(EXIT_FAILURE);