mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-13 19:49:57 +08:00
chg: use calloc
This commit is contained in:
parent
18db34ffb0
commit
ed7122e409
3 changed files with 7 additions and 7 deletions
|
@ -415,7 +415,7 @@ int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
|
|||
char * GenerateFilename(const char *prefix, const char *suffix){
|
||||
uint8_t uid[10] = {0,0,0,0,0,0,0,0,0,0};
|
||||
int uidlen=0;
|
||||
char * fptr = malloc (sizeof (char) * (strlen(prefix) + strlen(suffix)) + sizeof(uid)*2 + 1);
|
||||
char * fptr = calloc (sizeof (char) * (strlen(prefix) + strlen(suffix)) + sizeof(uid)*2 + 1, sizeof(uint8_t));
|
||||
|
||||
GetHFMF14AUID(uid, &uidlen);
|
||||
if (!uidlen) {
|
||||
|
@ -2195,7 +2195,7 @@ int CmdHF14AMfSniff(const char *Cmd){
|
|||
if (traceLen > bufsize || buf == NULL) {
|
||||
uint8_t *p;
|
||||
if (buf == NULL) // not yet allocated
|
||||
p = malloc(traceLen);
|
||||
p = calloc(traceLen, sizeof(uint8_t));
|
||||
else // need more memory
|
||||
p = realloc(buf, traceLen);
|
||||
|
||||
|
@ -2912,7 +2912,7 @@ int CmdHF14AMfCSave(const char *Cmd) {
|
|||
|
||||
if (errors || cmdp == 0) return usage_hf14_csave();
|
||||
|
||||
dump = malloc(bytes);
|
||||
dump = calloc(bytes, sizeof(uint8_t));
|
||||
if (!dump) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return 1;
|
||||
|
|
|
@ -194,7 +194,7 @@ static int topaz_print_CC(uint8_t *data) {
|
|||
PrintAndLogEx(NORMAL, " %02x: version %d.%d supported by tag", data[1], (data[1] & 0xF0) >> 4, data[1] & 0x0f);
|
||||
uint16_t memsize = (data[2] + 1) * 8;
|
||||
topaz_tag.size = memsize;
|
||||
topaz_tag.dynamic_memory = malloc(memsize - TOPAZ_STATIC_MEMORY);
|
||||
topaz_tag.dynamic_memory = calloc(memsize - TOPAZ_STATIC_MEMORY, sizeof(uint8_t));
|
||||
PrintAndLogEx(NORMAL, " %02x: Physical Memory Size of this tag: %d bytes", data[2], memsize);
|
||||
PrintAndLogEx(NORMAL, " %02x: %s / %s", data[3],
|
||||
(data[3] & 0xF0) ? "(RFU)" : "Read access granted without any security",
|
||||
|
@ -278,12 +278,12 @@ static void topaz_print_control_TLVs(uint8_t *memory) {
|
|||
dynamic_lock_area_t *old = topaz_tag.dynamic_lock_areas;
|
||||
dynamic_lock_area_t *new = topaz_tag.dynamic_lock_areas;
|
||||
if (old == NULL) {
|
||||
new = topaz_tag.dynamic_lock_areas = (dynamic_lock_area_t *)malloc(sizeof(dynamic_lock_area_t));
|
||||
new = topaz_tag.dynamic_lock_areas = (dynamic_lock_area_t *) calloc(sizeof(dynamic_lock_area_t, sizeof(uint8_t)));
|
||||
} else {
|
||||
while(old->next != NULL) {
|
||||
old = old->next;
|
||||
}
|
||||
new = old->next = (dynamic_lock_area_t *)malloc(sizeof(dynamic_lock_area_t));
|
||||
new = old->next = (dynamic_lock_area_t *) calloc(sizeof(dynamic_lock_area_t), sizeof(uint8_t));
|
||||
}
|
||||
new->next = NULL;
|
||||
if (area_start <= next_lockable_byte) {
|
||||
|
|
|
@ -1012,7 +1012,7 @@ int CmdSmartBruteforceSFI(const char *Cmd) {
|
|||
json_t *root = NULL;
|
||||
smart_loadjson("aidlist", "json", &root);
|
||||
|
||||
uint8_t* buf = malloc(USB_CMD_DATA_SIZE);
|
||||
uint8_t* buf = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||
if ( !buf )
|
||||
return 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue