X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/a7474bb30acb4881fe57db4c8ce0778823efa501..4bb17c66333da6ac8ed6c4757f8377d37f7f7e24:/client/cmdhficlass.c diff --git a/client/cmdhficlass.c b/client/cmdhficlass.c index ffcd719e..86524cd6 100644 --- a/client/cmdhficlass.c +++ b/client/cmdhficlass.c @@ -269,10 +269,9 @@ int CmdHFiClassELoad(const char *Cmd) { //File handling and reading FILE *f; char filename[FILE_PATH_SIZE]; - if(opt == 'f' && param_getstr(Cmd, 1, filename) > 0) - { + if(opt == 'f' && param_getstr(Cmd, 1, filename) > 0) { f = fopen(filename, "rb"); - }else{ + } else { return hf_iclass_eload_usage(); } @@ -285,8 +284,13 @@ int CmdHFiClassELoad(const char *Cmd) { long fsize = ftell(f); fseek(f, 0, SEEK_SET); - uint8_t *dump = malloc(fsize); + if (fsize < 0) { + prnlog("Error, when getting filesize"); + fclose(f); + return 1; + } + uint8_t *dump = malloc(fsize); size_t bytes_read = fread(dump, 1, fsize, f); fclose(f); @@ -409,6 +413,7 @@ int CmdHFiClassDecrypt(const char *Cmd) { saveFile(outfilename,"bin", decrypted, blocknum*8); + free(decrypted); return 0; } @@ -1504,6 +1509,12 @@ static int loadKeys(char *filename) { long fsize = ftell(f); fseek(f, 0, SEEK_SET); + if ( fsize < 0 ) { + PrintAndLog("Error, when getting filesize"); + fclose(f); + return 1; + } + uint8_t *dump = malloc(fsize); size_t bytes_read = fread(dump, 1, fsize, f);