]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge pull request #534 from pwpiwi/fix_printf
authorIceman <iceman@iuse.se>
Sat, 6 Jan 2018 17:54:09 +0000 (18:54 +0100)
committerGitHub <noreply@github.com>
Sat, 6 Jan 2018 17:54:09 +0000 (18:54 +0100)
Minor fixes

client/cmdhfmf.c
client/loclass/ikeys.c
client/ui.c

index 5ebf814498a1f18ff272051986fcad131969fe63..c471fdf73186f5b50d54193a45ff4f9e4b0175a3 100644 (file)
@@ -987,6 +987,7 @@ int CmdHF14AMfChk(const char *Cmd)
        int i, res;\r
        int     keycnt = 0;\r
        char ctmp       = 0x00;\r
+       int clen = 0;\r
        char ctmp3[3]   = {0x00};\r
        uint8_t blockNo = 0;\r
        uint8_t SectorsCnt = 0;\r
@@ -1015,32 +1016,36 @@ int CmdHF14AMfChk(const char *Cmd)
                blockNo = param_get8(Cmd, 0);\r
 \r
        ctmp = param_getchar(Cmd, 1);\r
-       switch (ctmp) {\r
-       case 'a': case 'A':\r
-               keyType = 0;\r
-               break;\r
-       case 'b': case 'B':\r
-               keyType = 1;\r
-               break;\r
-       case '?':\r
-               keyType = 2;\r
-               break;\r
-       default:\r
-               PrintAndLog("Key type must be A , B or ?");\r
-               free(keyBlock);\r
-               return 1;\r
-       };\r
+       clen = param_getlength(Cmd, 1);\r
+       if (clen == 1) {\r
+               switch (ctmp) {\r
+               case 'a': case 'A':\r
+                       keyType = 0;\r
+                       break;\r
+               case 'b': case 'B':\r
+                       keyType = 1;\r
+                       break;\r
+               case '?':\r
+                       keyType = 2;\r
+                       break;\r
+               default:\r
+                       PrintAndLog("Key type must be A , B or ?");\r
+                       free(keyBlock);\r
+                       return 1;\r
+               };\r
+       }\r
 \r
        // transfer to emulator & create dump file\r
        ctmp = param_getchar(Cmd, 2);\r
-       if (ctmp == 't' || ctmp == 'T') transferToEml = 1;\r
-       if (ctmp == 'd' || ctmp == 'D') createDumpFile = 1;\r
+       clen = param_getlength(Cmd, 2);\r
+       if (clen == 1 && (ctmp == 't' || ctmp == 'T')) transferToEml = 1;\r
+       if (clen == 1 && (ctmp == 'd' || ctmp == 'D')) createDumpFile = 1;\r
        \r
        param3InUse = transferToEml | createDumpFile;\r
        \r
        timeout14a = 500; // fast by default\r
        // double parameters - ts, ds\r
-       int clen = param_getlength(Cmd, 2);\r
+       clen = param_getlength(Cmd, 2);\r
        if (clen == 2 || clen == 3){\r
                param_getstr(Cmd, 2, ctmp3, sizeof(ctmp3));\r
                ctmp = ctmp3[1];\r
index 72acf6906d6a61bc18db1a6f2e9e604ce543e13d..2a6a00109297c72afe47de08426814f37a510f7e 100644 (file)
@@ -739,18 +739,16 @@ int readKeyFile(uint8_t key[8])
        FILE *f;
        int retval = 1;
        f = fopen("iclass_key.bin", "rb");
-       if (f)
-       {
-               if(fread(key, sizeof(uint8_t), 8, f) == 1) 
-               {
-                       retval = 0;     
-               }
-               fclose(f);
+       if (!f)
+               return retval;
+       
+       if (fread(key, sizeof(uint8_t), 8, f) == 8) {
+               retval = 0;
        }
+       fclose(f);      
        return retval;
 }
 
-
 int doKeyTests(uint8_t debuglevel)
 {
        debug_print = debuglevel;
index df2c3ce3c6a6909cb99317f34770853c40992f13..8faed6e86cae50f34849dcd4b53b8337cfb03528 100644 (file)
@@ -9,12 +9,14 @@
 // UI utilities
 //-----------------------------------------------------------------------------
 
-#include <stdarg.h>
+#include <stdbool.h>
+#ifndef EXTERNAL_PRINTANDLOG
 #include <stdlib.h>
 #include <stdio.h>
-#include <stdbool.h>
+#include <stdarg.h>
 #include <readline/readline.h>
 #include <pthread.h>
+#endif
 
 #include "ui.h"
 
@@ -26,10 +28,12 @@ int GridOffset = 0;
 bool GridLocked = false;
 bool showDemod = true;
 
-extern pthread_mutex_t print_lock;
-
 static char *logfilename = "proxmark3.log";
 
+#ifndef EXTERNAL_PRINTANDLOG
+// Declared in proxmark3.c
+extern pthread_mutex_t print_lock;
+
 void PrintAndLog(char *fmt, ...)
 {
        char *saved_line;
@@ -94,7 +98,7 @@ void PrintAndLog(char *fmt, ...)
        //release lock
        pthread_mutex_unlock(&print_lock);  
 }
-
+#endif
 
 void SetLogFilename(char *fn)
 {
Impressum, Datenschutz