]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhficlass.c
verify wait isn't null
[proxmark3-svn] / client / cmdhficlass.c
index 54b780c7c42ff1594c3e7d36d3d173c80e5c9fa2..134ca21e07d8424130f5ef5ee6ea1a592a08527f 100644 (file)
@@ -33,8 +33,6 @@
 #include "usb_cmd.h"
 #include "cmdhfmfu.h"
 
-#define llX PRIx64
-
 static int CmdHelp(const char *Cmd);
 
 #define ICLASS_KEYS_MAX 8
@@ -373,10 +371,13 @@ int CmdHFiClassDecrypt(const char *Cmd) {
        //Open the tagdump-file
        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{
+               if ( f == NULL ) {
+                       PrintAndLog("Could not find file %s", filename);
+                       return 1;
+               }
+       } else {
                return usage_hf_iclass_decrypt();
        }
 
@@ -938,7 +939,7 @@ int usage_hf_iclass_clone(void) {
 }
 
 int CmdHFiClassCloneTag(const char *Cmd) {
-       char filename[FILE_PATH_SIZE];
+       char filename[FILE_PATH_SIZE] = {0};
        char tempStr[50]={0};
        uint8_t KEY[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
        uint8_t keyNbr = 0;
@@ -1043,6 +1044,7 @@ int CmdHFiClassCloneTag(const char *Cmd) {
 
        if (startblock<5) {
                PrintAndLog("You cannot write key blocks this way. yet... make your start block > 4");
+               fclose(f);
                return 0;
        }
        // now read data from the file from block 6 --- 19
@@ -1346,7 +1348,7 @@ uint64_t hexarray_to_uint64(uint8_t *key) {
        for (int i = 0;i < 8;i++)
                sprintf(&temp[(i *2)],"%02X",key[i]);
        temp[16] = '\0';
-       if (sscanf(temp,"%016"llX,&uint_key) < 1)
+       if (sscanf(temp,"%016"llx,&uint_key) < 1)
                return 0;
        return uint_key;
 }
Impressum, Datenschutz