mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-12 18:25:07 +08:00
Added security features to the loadFileDICTIONARY_safe function (memset after a realloc).
This commit is contained in:
parent
1ce10cfea6
commit
7eb79732ff
1 changed files with 7 additions and 2 deletions
|
@ -673,7 +673,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, uint8_t **data, uint8_t k
|
|||
char line[255];
|
||||
|
||||
// allocate some space for the dictionary
|
||||
*data = (uint8_t*) malloc(keylen * allocation_size * sizeof(uint8_t));
|
||||
*data = (uint8_t*) calloc(keylen * allocation_size, sizeof(uint8_t));
|
||||
if (*data == NULL) return PM3_EFILE;
|
||||
|
||||
FILE *f = fopen(path, "r");
|
||||
|
@ -688,7 +688,12 @@ int loadFileDICTIONARY_safe(const char *preferredName, uint8_t **data, uint8_t k
|
|||
if ((*keycnt) >= allocation_size) {
|
||||
allocation_size += block_size;
|
||||
*data = (uint8_t*) realloc((void*) *data, keylen * allocation_size * sizeof(uint8_t));
|
||||
if (*data == NULL) return PM3_EFILE;
|
||||
if (*data == NULL) {
|
||||
return PM3_EFILE;
|
||||
} else {
|
||||
// zero the new memeory (safety first)
|
||||
memset(*data + counter, 0, block_size);
|
||||
}
|
||||
}
|
||||
|
||||
// add null terminator
|
||||
|
|
Loading…
Reference in a new issue