]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX, Coverity, Argument can't be negative. CID# 212322, ftell(f) can be negative...
authoriceman1001 <iceman@iuse.se>
Tue, 12 Jan 2016 21:43:28 +0000 (22:43 +0100)
committericeman1001 <iceman@iuse.se>
Tue, 12 Jan 2016 21:43:28 +0000 (22:43 +0100)
client/cmdhficlass.c

index 75c45444a7996566cc34ff9bbc85fba000244e4c..d475073572a7fd1c9c1035fa0e575b7f9314e0d9 100644 (file)
@@ -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,9 +284,14 @@ 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");
+               return 1;
+       }
 
 
+       uint8_t *dump = malloc(fsize);
+
        size_t bytes_read = fread(dump, 1, fsize, f);
        fclose(f);
 
Impressum, Datenschutz