mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
fix: lf cmdread
silent lost CRC
This commit is contained in:
parent
edb74d084e
commit
424a467132
1 changed files with 9 additions and 3 deletions
|
@ -241,6 +241,8 @@ static int CmdLFTune(const char *Cmd) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PAYLOAD_HEADER_SIZE (12 + (3 * LF_CMDREAD_MAX_EXTRA_SYMBOLS))
|
||||||
|
|
||||||
/* send a LF command before reading */
|
/* send a LF command before reading */
|
||||||
int CmdLFCommandRead(const char *Cmd) {
|
int CmdLFCommandRead(const char *Cmd) {
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
|
@ -274,7 +276,7 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||||
uint32_t delay = arg_get_u32_def(ctx, 1, 0);
|
uint32_t delay = arg_get_u32_def(ctx, 1, 0);
|
||||||
|
|
||||||
char cmd[128] = {0};
|
char cmd[PM3_CMD_DATA_SIZE - PAYLOAD_HEADER_SIZE] = {0};
|
||||||
int cmd_len = sizeof(cmd) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated
|
int cmd_len = sizeof(cmd) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated
|
||||||
CLIGetStrWithReturn(ctx, 2, (uint8_t *)cmd, &cmd_len);
|
CLIGetStrWithReturn(ctx, 2, (uint8_t *)cmd, &cmd_len);
|
||||||
|
|
||||||
|
@ -295,7 +297,6 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||||
return PM3_ENOTTY;
|
return PM3_ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PAYLOAD_HEADER_SIZE (12 + (3 * LF_CMDREAD_MAX_EXTRA_SYMBOLS))
|
|
||||||
struct p {
|
struct p {
|
||||||
uint32_t delay;
|
uint32_t delay;
|
||||||
uint16_t period_0;
|
uint16_t period_0;
|
||||||
|
@ -316,7 +317,12 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||||
memset(payload.symbol_extra, 0, sizeof(payload.symbol_extra));
|
memset(payload.symbol_extra, 0, sizeof(payload.symbol_extra));
|
||||||
memset(payload.period_extra, 0, sizeof(payload.period_extra));
|
memset(payload.period_extra, 0, sizeof(payload.period_extra));
|
||||||
|
|
||||||
if (add_crc_ht && (cmd_len <= 120)) {
|
if (cmd_len > sizeof(payload.data) - 8 * add_crc_ht - 1) {
|
||||||
|
PrintAndLogEx(ERR, "cmd too long, max length is %zu", sizeof(cmd) - 1);
|
||||||
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (add_crc_ht) {
|
||||||
// Hitag 1, Hitag S, ZX8211
|
// Hitag 1, Hitag S, ZX8211
|
||||||
// width=8 poly=0x1d init=0xff refin=false refout=false xorout=0x00 check=0xb4 residue=0x00 name="CRC-8/HITAG"
|
// width=8 poly=0x1d init=0xff refin=false refout=false xorout=0x00 check=0xb4 residue=0x00 name="CRC-8/HITAG"
|
||||||
crc_t crc;
|
crc_t crc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue