fix lf sniff input values to be atleast a bit limited

This commit is contained in:
iceman1001 2022-04-10 13:17:21 +02:00
commit 77520ce489

View file

@ -746,11 +746,10 @@ int lf_sniff(bool verbose, uint32_t samples) {
struct p { struct p {
uint32_t samples : 31; uint32_t samples : 31;
bool verbose : 1; bool verbose : 1;
} PACKED; } PACKED payload;
struct p payload; payload.samples = (samples & 0xFFFF);
payload.verbose = verbose; payload.verbose = verbose;
payload.samples = samples;
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_LF_SNIFF_RAW_ADC, (uint8_t *)&payload, sizeof(payload)); SendCommandNG(CMD_LF_SNIFF_RAW_ADC, (uint8_t *)&payload, sizeof(payload));
@ -758,7 +757,7 @@ int lf_sniff(bool verbose, uint32_t samples) {
if (gs_lf_threshold_set) { if (gs_lf_threshold_set) {
WaitForResponse(CMD_LF_SNIFF_RAW_ADC, &resp); WaitForResponse(CMD_LF_SNIFF_RAW_ADC, &resp);
} else { } else {
if (!WaitForResponseTimeout(CMD_LF_SNIFF_RAW_ADC, &resp, 2500)) { if (WaitForResponseTimeout(CMD_LF_SNIFF_RAW_ADC, &resp, 2500) == false) {
PrintAndLogEx(WARNING, "(lf_read) command execution time out"); PrintAndLogEx(WARNING, "(lf_read) command execution time out");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
@ -791,7 +790,7 @@ int CmdLFSniff(const char *Cmd) {
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, true); CLIExecWithReturn(ctx, Cmd, argtable, true);
uint32_t samples = arg_get_u32_def(ctx, 1, 0); uint32_t samples = (arg_get_u32_def(ctx, 1, 0) & 0xFFFF);
bool verbose = arg_get_lit(ctx, 2); bool verbose = arg_get_lit(ctx, 2);
bool cm = arg_get_lit(ctx, 3); bool cm = arg_get_lit(ctx, 3);
CLIParserFree(ctx); CLIParserFree(ctx);