Skip to content

Commit

Permalink
fix CID #416734
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed Aug 29, 2023
1 parent b90326b commit 0cbc0c2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions client/src/cmdhficlass.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,27 +1238,27 @@ static int CmdHFiClassESetBlk(const char *Cmd) {

int blk = arg_get_int_def(ctx, 1, 0);

if (blk > 255) {
PrintAndLogEx(WARNING, "block number must be between 0 and 255. Got %i", blk);
if (blk > 255 || blk < 0) {
PrintAndLogEx(WARNING, "block number must be between 0 and 255. Got " _RED_("%i"), blk);
CLIParserFree(ctx);
return PM3_EINVARG;
}

uint8_t data[PICOPASS_BLOCK_SIZE] = {0x00};
int datalen = 0;
int res = CLIParamHexToBuf(arg_get_str(ctx, 2), data, sizeof(data), &datalen);
CLIParserFree(ctx);

if (res) {
PrintAndLogEx(FAILED, "Error parsing bytes");
return PM3_EINVARG;
}

if (datalen != sizeof(data)) {
PrintAndLogEx(WARNING, "block data must include 8 HEX bytes. Got %i", datalen);
if (datalen != PICOPASS_BLOCK_SIZE) {
PrintAndLogEx(WARNING, "block data must include 8 HEX bytes. Got " _RED_("%i"), datalen);
return PM3_EINVARG;
}

CLIParserFree(ctx);

uint16_t bytes_sent = 0;
iclass_upload_emul(data, sizeof(data), blk * PICOPASS_BLOCK_SIZE, &bytes_sent);

Expand Down Expand Up @@ -1805,7 +1805,6 @@ static int CmdHFiClassDump(const char *Cmd) {
uint8_t tag_data[0x100 * 8];
memset(tag_data, 0xFF, sizeof(tag_data));


iclass_card_select_t payload_rdr = {
.flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE)
};
Expand Down

0 comments on commit 0cbc0c2

Please sign in to comment.