mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
chg: calloc calls
This commit is contained in:
parent
5f2ecf67cd
commit
66c82d16b0
3 changed files with 6 additions and 6 deletions
|
@ -2463,7 +2463,7 @@ static void shave(uint8_t *data, uint8_t len){
|
||||||
data[i] &= 0xFE;
|
data[i] &= 0xFE;
|
||||||
}
|
}
|
||||||
static void generate_rev(uint8_t *data, uint8_t len) {
|
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));
|
PrintAndLogEx(SUCCESS, "input permuted key | %s \n", sprint_hex(data, len));
|
||||||
permute_rev(data, len, key);
|
permute_rev(data, len, key);
|
||||||
PrintAndLogEx(SUCCESS, " unpermuted key | %s \n", sprint_hex(key, len));
|
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);
|
free(key);
|
||||||
}
|
}
|
||||||
static void generate(uint8_t *data, uint8_t len) {
|
static void generate(uint8_t *data, uint8_t len) {
|
||||||
uint8_t *key = calloc(len,1);
|
uint8_t *key = calloc(len, sizeof(uint8_t));
|
||||||
uint8_t *pkey = calloc(len,1);
|
uint8_t *pkey = calloc(len, sizeof(uint8_t));
|
||||||
PrintAndLogEx(SUCCESS, " input key | %s \n", sprint_hex(data, len));
|
PrintAndLogEx(SUCCESS, " input key | %s \n", sprint_hex(data, len));
|
||||||
permute(data, len, pkey);
|
permute(data, len, pkey);
|
||||||
PrintAndLogEx(SUCCESS, "permuted key | %s \n", sprint_hex(pkey, len));
|
PrintAndLogEx(SUCCESS, "permuted key | %s \n", sprint_hex(pkey, len));
|
||||||
|
|
|
@ -483,7 +483,7 @@ int CmdLegicRdmem(const char *Cmd) {
|
||||||
PrintAndLogEx(NORMAL, "Reading %d bytes, from offset %d", len, offset);
|
PrintAndLogEx(NORMAL, "Reading %d bytes, from offset %d", len, offset);
|
||||||
|
|
||||||
// allocate receiver buffer
|
// allocate receiver buffer
|
||||||
uint8_t *data = malloc(len);
|
uint8_t *data = calloc(len, sizeof(uint8_t));
|
||||||
if ( !data ){
|
if ( !data ){
|
||||||
PrintAndLogEx(WARNING, "Cannot allocate memory");
|
PrintAndLogEx(WARNING, "Cannot allocate memory");
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -923,7 +923,7 @@ int CmdLegicDump(const char *Cmd){
|
||||||
else
|
else
|
||||||
sprintf(fnameptr + fileNlen,".bin");
|
sprintf(fnameptr + fileNlen,".bin");
|
||||||
|
|
||||||
f = fopen(filename,"wb");
|
f = fopen(filename, "wb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
PrintAndLogEx(WARNING, "Could not create file name %s", filename);
|
PrintAndLogEx(WARNING, "Could not create file name %s", filename);
|
||||||
if (data)
|
if (data)
|
||||||
|
|
|
@ -2496,7 +2496,7 @@ int CmdHF14AMfESave(const char *Cmd) {
|
||||||
blocks = NumOfBlocks(c);
|
blocks = NumOfBlocks(c);
|
||||||
bytes = blocks * MFBLOCK_SIZE;
|
bytes = blocks * MFBLOCK_SIZE;
|
||||||
|
|
||||||
dump = calloc(sizeof(uint8_t), bytes);
|
dump = calloc(bytes, sizeof(uint8_t));
|
||||||
if (!dump) {
|
if (!dump) {
|
||||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue