From 66c82d16b0671f48b0f2c0b715676099d78b0f35 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 21 Jan 2019 09:02:00 +0100 Subject: [PATCH] chg: calloc calls --- client/cmdhficlass.c | 6 +++--- client/cmdhflegic.c | 4 ++-- client/cmdhfmf.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/cmdhficlass.c b/client/cmdhficlass.c index 0e62afaf6..f0bfa18a0 100644 --- a/client/cmdhficlass.c +++ b/client/cmdhficlass.c @@ -2463,7 +2463,7 @@ static void shave(uint8_t *data, uint8_t len){ data[i] &= 0xFE; } static void generate_rev(uint8_t *data, uint8_t len) { - uint8_t *key = calloc(len,1); + uint8_t *key = calloc(len, sizeof(uint8_t)); PrintAndLogEx(SUCCESS, "input permuted key | %s \n", sprint_hex(data, len)); permute_rev(data, len, key); PrintAndLogEx(SUCCESS, " unpermuted key | %s \n", sprint_hex(key, len)); @@ -2472,8 +2472,8 @@ static void generate_rev(uint8_t *data, uint8_t len) { free(key); } static void generate(uint8_t *data, uint8_t len) { - uint8_t *key = calloc(len,1); - uint8_t *pkey = calloc(len,1); + uint8_t *key = calloc(len, sizeof(uint8_t)); + uint8_t *pkey = calloc(len, sizeof(uint8_t)); PrintAndLogEx(SUCCESS, " input key | %s \n", sprint_hex(data, len)); permute(data, len, pkey); PrintAndLogEx(SUCCESS, "permuted key | %s \n", sprint_hex(pkey, len)); diff --git a/client/cmdhflegic.c b/client/cmdhflegic.c index 393d73ed0..a31dbd1b1 100644 --- a/client/cmdhflegic.c +++ b/client/cmdhflegic.c @@ -483,7 +483,7 @@ int CmdLegicRdmem(const char *Cmd) { PrintAndLogEx(NORMAL, "Reading %d bytes, from offset %d", len, offset); // allocate receiver buffer - uint8_t *data = malloc(len); + uint8_t *data = calloc(len, sizeof(uint8_t)); if ( !data ){ PrintAndLogEx(WARNING, "Cannot allocate memory"); return 2; @@ -923,7 +923,7 @@ int CmdLegicDump(const char *Cmd){ else sprintf(fnameptr + fileNlen,".bin"); - f = fopen(filename,"wb"); + f = fopen(filename, "wb"); if (!f) { PrintAndLogEx(WARNING, "Could not create file name %s", filename); if (data) diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 00e29105f..a02302b15 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -2496,7 +2496,7 @@ int CmdHF14AMfESave(const char *Cmd) { blocks = NumOfBlocks(c); bytes = blocks * MFBLOCK_SIZE; - dump = calloc(sizeof(uint8_t), bytes); + dump = calloc(bytes, sizeof(uint8_t)); if (!dump) { PrintAndLogEx(WARNING, "Fail, cannot allocate memory"); return 1;