diff --git a/client/cmdhfepa.c b/client/cmdhfepa.c index 0386155c1..ecd185783 100644 --- a/client/cmdhfepa.c +++ b/client/cmdhfepa.c @@ -61,8 +61,8 @@ int CmdHFEPACollectPACENonces(const char *Cmd) { // perform the PACE protocol by replaying APDUs int CmdHFEPAPACEReplay(const char *Cmd) { // the 4 APDUs which are replayed + their lengths - uint8_t msesa_apdu[41], gn_apdu[8], map_apdu[75]; - uint8_t pka_apdu[75], ma_apdu[18], apdu_lengths[5] = {0}; + uint8_t msesa_apdu[41] = {0}, gn_apdu[8] = {0}, map_apdu[75] = {0}; + uint8_t pka_apdu[75] = {0}, ma_apdu[18] = {0}, apdu_lengths[5] = {0}; // pointers to the arrays to be able to iterate uint8_t *apdus[] = {msesa_apdu, gn_apdu, map_apdu, pka_apdu, ma_apdu}; @@ -74,15 +74,18 @@ int CmdHFEPAPACEReplay(const char *Cmd) { // Proxmark response UsbCommand resp; - int skip = 0, skip_add = 0, scan_return = 0; + int skip = 0, skip_add = 0, scan_return; // for each APDU for (int i = 0; i < sizeof(apdu_lengths); i++) { // scan to next space or end of string while (Cmd[skip] != ' ' && Cmd[skip] != '\0') { // convert - scan_return = sscanf(Cmd + skip, "%2X%n", + scan_return = sscanf(Cmd + skip, + "%2X%n", (unsigned int *)(apdus[i] + apdu_lengths[i]), - &skip_add); + &skip_add + ); + if (scan_return < 1) { PrintAndLogEx(NORMAL, (char *)usage_msg); PrintAndLogEx(WARNING, "Not enough APDUs! Try again!");