1 parent
3628681a50
commit
9df1c62ec5
6 files changed
+17
-15
No files matched your search
+10
-8
@@ -161,19 +161,21 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
||||
g_conn.block_after_ACK = true;
|
||||
for (int i = 0; i < ARRAYLEN(apdu_lengths); i++) {
|
||||
|
||||
// chunk size = what fits one frame to THIS device, minus the reply header
|
||||
const int chunk = (int)(pm3_max_cmd_data_size() - sizeof(epa_replay_t));
|
||||
// transfer the APDU in several parts if necessary
|
||||
for (int j = 0; j * sizeof(data) < apdu_lengths[i]; j++) {
|
||||
for (int j = 0; j * chunk < apdu_lengths[i]; j++) {
|
||||
// amount of data in this packet
|
||||
int packet_length = apdu_lengths[i] - (j * sizeof(data));
|
||||
if (packet_length > sizeof(data)) {
|
||||
packet_length = sizeof(data);
|
||||
int packet_length = apdu_lengths[i] - (j * chunk);
|
||||
if (packet_length > chunk) {
|
||||
packet_length = chunk;
|
||||
}
|
||||
if ((i == ARRAYLEN(apdu_lengths) - 1) && (j * sizeof(data) >= apdu_lengths[i] - 1)) {
|
||||
if ((i == ARRAYLEN(apdu_lengths) - 1) && (j * chunk >= apdu_lengths[i] - 1)) {
|
||||
// Disable fast mode on last packet
|
||||
g_conn.block_after_ACK = false;
|
||||
}
|
||||
memcpy(data, // + (j * sizeof(data)),
|
||||
apdus[i] + (j * sizeof(data)),
|
||||
memcpy(data, // + (j * chunk),
|
||||
apdus[i] + (j * chunk),
|
||||
packet_length);
|
||||
|
||||
clearCommandBuffer();
|
||||
@@ -182,7 +184,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
||||
uint8_t ubuf[sizeof(epa_replay_t) + sizeof(data)] = {0};
|
||||
epa_replay_t *upayload = (epa_replay_t *)ubuf;
|
||||
upayload->apdu_num = i + 1;
|
||||
upayload->offset = j * sizeof(data);
|
||||
upayload->offset = j * chunk;
|
||||
upayload->len = packet_length;
|
||||
memcpy(upayload->data, data, packet_length);
|
||||
|
||||
|
||||
@@ -702,7 +702,7 @@ static int VASGetData(const char *passIdentifier, const uint8_t *pidHash, bool h
|
||||
PrintAndLogEx(INFO, "Pass type id hash...... " _YELLOW_("%s"), hasPid ? sprint_hex_inrow(pidHash, 32) : "n/a");
|
||||
}
|
||||
|
||||
uint8_t getVasApdu[PM3_CMD_DATA_SIZE];
|
||||
uint8_t getVasApdu[512]; // GET VAS DATA APDU: 6 + reqTlvLen, urlLen capped at 256 => <= 319 bytes
|
||||
int getVasApduLen = 0;
|
||||
int s = CreateGetVASDataCommand(pidHash, url, urlLen, vas_mode, isFinalRequest, getVasApdu, &getVasApduLen);
|
||||
if (s != PM3_SUCCESS) {
|
||||
|
||||
+1
-1
@@ -360,7 +360,7 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||
memset(payload.period_extra, 0, sizeof(payload.period_extra));
|
||||
|
||||
if (cmd_len > (size_t)(pm3_max_cmd_data_size() - PAYLOAD_HEADER_SIZE) - 8 * add_crc_ht - 1) {
|
||||
PrintAndLogEx(ERR, "cmd too long, max length is %zu", sizeof(cmd) - 1);
|
||||
PrintAndLogEx(ERR, "cmd too long, max length is %zu", (size_t)(pm3_max_cmd_data_size() - PAYLOAD_HEADER_SIZE) - 8 * add_crc_ht - 1);
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
|
||||
@@ -1336,7 +1336,7 @@ static int CmdSmartBruteforceSFI(const char *Cmd) {
|
||||
|
||||
int hexlen = 0;
|
||||
uint8_t cmddata[PM3_CMD_DATA_SIZE];
|
||||
int res = param_gethex_to_eol(caid, 0, cmddata, sizeof(cmddata), &hexlen);
|
||||
int res = param_gethex_to_eol(caid, 0, cmddata, (int)(pm3_max_cmd_data_size() - sizeof(smart_card_raw_t)), &hexlen);
|
||||
if (res) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1139,7 +1139,7 @@ static int download_trace(void) {
|
||||
|
||||
gs_traceLen = 0;
|
||||
|
||||
gs_trace = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||
gs_trace = calloc(pm3_max_cmd_data_size(), sizeof(uint8_t));
|
||||
if (gs_trace == NULL) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
@@ -1149,7 +1149,7 @@ static int download_trace(void) {
|
||||
|
||||
// Query for the size of the trace, downloading PM3_CMD_DATA_SIZE
|
||||
PacketResponseNG resp;
|
||||
if (!GetFromDevice(BIG_BUF, gs_trace, PM3_CMD_DATA_SIZE, 0, NULL, 0, &resp, 4000, true)) {
|
||||
if (!GetFromDevice(BIG_BUF, gs_trace, pm3_max_cmd_data_size(), 0, NULL, 0, &resp, 4000, true)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply");
|
||||
free(gs_trace);
|
||||
gs_trace = NULL;
|
||||
@@ -1166,7 +1166,7 @@ static int download_trace(void) {
|
||||
gs_traceLen = ((const download_done_t *)resp.data.asBytes)->extra;
|
||||
|
||||
// if tracelog buffer was larger and we need to download more.
|
||||
if (gs_traceLen > PM3_CMD_DATA_SIZE) {
|
||||
if (gs_traceLen > pm3_max_cmd_data_size()) {
|
||||
|
||||
free(gs_trace);
|
||||
gs_trace = calloc(gs_traceLen, sizeof(uint8_t));
|
||||
|
||||
@@ -637,7 +637,7 @@ static int CmdUsartTXhex(const char *Cmd) {
|
||||
|
||||
int dlen = 0;
|
||||
uint8_t data[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
int res = CLIParamHexToBuf(arg_get_str(ctx, 1), data, sizeof(data), &dlen);
|
||||
int res = CLIParamHexToBuf(arg_get_str(ctx, 1), data, (int)pm3_max_cmd_data_size(), &dlen);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
if (res) {
|
||||
|
||||
Reference in new issue
Block a user