mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
lf sim: better to return err on faulty offset, thanks @iceman
This commit is contained in:
parent
b3f84bf7b3
commit
1410d4d9b5
1 changed files with 6 additions and 4 deletions
|
@ -1654,14 +1654,16 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
}
|
||||
|
||||
// offset should not be over buffer
|
||||
uint16_t offset = MIN(BIGBUF_SIZE - 1, payload->offset);
|
||||
|
||||
if (payload->offset >= BIGBUF_SIZE) {
|
||||
reply_ng(CMD_LF_UPLOAD_SIM_SAMPLES, PM3_EOVFLOW, NULL, 0);
|
||||
break;
|
||||
}
|
||||
// ensure len bytes copied wont go past end of bigbuf
|
||||
uint16_t len = MIN(BIGBUF_SIZE - offset, sizeof(payload->data));
|
||||
uint16_t len = MIN(BIGBUF_SIZE - payload->offset, sizeof(payload->data));
|
||||
|
||||
uint8_t *mem = BigBuf_get_addr();
|
||||
|
||||
memcpy(mem + offset, &payload->data, len);
|
||||
memcpy(mem + payload->offset, &payload->data, len);
|
||||
reply_ng(CMD_LF_UPLOAD_SIM_SAMPLES, PM3_SUCCESS, NULL, 0);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue