]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge pull request #533 from merlokk/chktd
authorIceman <iceman@iuse.se>
Sat, 30 Dec 2017 14:23:14 +0000 (15:23 +0100)
committerGitHub <noreply@github.com>
Sat, 30 Dec 2017 14:23:14 +0000 (15:23 +0100)
fix #532. looks at length of parameters.

client/cmdcrc.c
client/cmdhf14a.c
client/cmdhfmf.c
client/cmdlft55xx.c
client/emv/cmdemv.c
client/pm3_binlib.c
client/reveng/model.c
client/ui.c
client/util.c

index 27d081b911de0c459206092d40473020d4002b17..0ca2b8b1e00d816223d991f49d23978dc8f10739 100644 (file)
@@ -40,14 +40,14 @@ int split(char *str, char *arr[MAX_ARGS]){
        int wordCnt = 0;
 
        while(1){
-               while(isspace(str[beginIndex])){
+               while(isspace((unsigned char)str[beginIndex])){
                        ++beginIndex;
                }
                if(str[beginIndex] == '\0') {
                        break;
                }
                endIndex = beginIndex;
-               while (str[endIndex] && !isspace(str[endIndex])){
+               while (str[endIndex] && !isspace((unsigned char)str[endIndex])){
                        ++endIndex;
                }
                int len = endIndex - beginIndex;
index 8064724cc3185a66b2e86f0c38c4bb8baaf9646c..e4b245c36e0a8e0c1802063268ca8481fd44bb77 100644 (file)
@@ -16,6 +16,7 @@
 #include <inttypes.h>
 #include <string.h>
 #include <unistd.h>
+#include <ctype.h>
 #include "util.h"
 #include "util_posix.h"
 #include "iso14443crc.h"
@@ -764,7 +765,7 @@ int CmdHF14AAPDU(const char *cmd) {
                                        return 1;
                        }
                        
-               if (isxdigit(c)) {
+               if (isxdigit((unsigned char)c)) {
                        // len = data + PCB(1b) + CRC(2b)
                        switch(param_gethex_to_eol(cmd, cmdp, data, sizeof(data) - 1 - 2, &datalen)) {
                        case 1:
index cca4da88bdd04ed0ace3d044efaceebba70da8a1..c471fdf73186f5b50d54193a45ff4f9e4b0175a3 100644 (file)
@@ -1094,7 +1094,7 @@ int CmdHF14AMfChk(const char *Cmd)
 \r
                                        if( buf[0]=='#' ) continue;     //The line start with # is comment, skip\r
 \r
-                                       if (!isxdigit(buf[0])){\r
+                                       if (!isxdigit((unsigned char)buf[0])){\r
                                                PrintAndLog("File content error. '%s' must include 12 HEX symbols",buf);\r
                                                continue;\r
                                        }\r
index 92a00bce5820f7e63dd4675c12ac1ec118f2567a..c5a6dd3f64623ed304c2487b50ae0238dedb7602 100644 (file)
@@ -1433,7 +1433,7 @@ int CmdT55xxBruteForce(const char *Cmd) {
                        //The line start with # is comment, skip\r
                        if( buf[0]=='#' ) continue;\r
 \r
-                       if (!isxdigit(buf[0])) {\r
+                       if (!isxdigit((unsigned char)buf[0])) {\r
                                PrintAndLog("File content error. '%s' must include 8 HEX symbols", buf);\r
                                continue;\r
                        }\r
index 42c8524aaaa897e80df91033e6b3dda6811060d0..c53b02af1a1dd1e4e58225a0f2dc905332e312ae 100644 (file)
@@ -8,6 +8,7 @@
 // EMV commands
 //-----------------------------------------------------------------------------
 
+#include <ctype.h>
 #include "cmdemv.h"
 #include "test/cryptotest.h"
 
@@ -69,7 +70,7 @@ int CmdHFEMVSelect(const char *cmd) {
                                        return 1;
                }
 
-               if (isxdigit(c)) {
+               if (isxdigit((unsigned char)c)) {
                        switch(param_gethex_to_eol(cmd, cmdp, data, sizeof(data), &datalen)) {
                        case 1:
                                PrintAndLog("Invalid HEX value.");
index ed46c8e805d76debb2c247a700c9d381878a0d13..cffbca6cd3995f18dae85b5ec1be5236bd8086a2 100644 (file)
@@ -306,7 +306,7 @@ static int l_pack(lua_State *L)             /** pack(f,...) */
         sbyte = 0;
         odd = 0;
       }
-    } else if (isspace(a[ii])) {
+    } else if (isspace((unsigned char)a[ii])) {
       /* ignore */
     } else {
       /* err ... ignore too*/
index 2d45b2fe1f9b29ebaf779bd1a532f504df4a628b..5a9b6580449dd20a7343f1e1e1c3e52ee4e28996 100644 (file)
@@ -596,7 +596,7 @@ mbynam(model_t *dest, const char *key) {
                uerror("cannot allocate memory for comparison string");
        akey.name = uptr = ukey;
        do
-               *uptr++ = toupper(*key);
+               *uptr++ = toupper((unsigned char)*key);
        while(*key++);
 
        aptr = bsearch(&akey, aliases, NALIASES, sizeof(struct malias), (int (*)(const void *, const void *)) &acmp);
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)
 {
index b7f07bde056ec5b79834088a77de8d466b08a358..7e6b40742c1a7fa2ecb596481e30dae8f9e290ac 100644 (file)
@@ -496,7 +496,7 @@ int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt)
                return 1;
 
        for(i = 0; i < hexcnt; i += 2) {
-               if (!(isxdigit(line[bg + i]) && isxdigit(line[bg + i + 1])) )   return 1;
+               if (!(isxdigit((unsigned char)line[bg + i]) && isxdigit((unsigned char)line[bg + i + 1])) )     return 1;
                
                sscanf((char[]){line[bg + i], line[bg + i + 1], 0}, "%X", &temp);
                data[i / 2] = temp & 0xff;
@@ -518,7 +518,7 @@ int param_gethex_ex(const char *line, int paramnum, uint8_t * data, int *hexcnt)
                return 1;
 
        for(i = 0; i < *hexcnt; i += 2) {
-               if (!(isxdigit(line[bg + i]) && isxdigit(line[bg + i + 1])) )   return 1;
+               if (!(isxdigit((unsigned char)line[bg + i]) && isxdigit((unsigned char)line[bg + i + 1])) )     return 1;
                
                sscanf((char[]){line[bg + i], line[bg + i + 1], 0}, "%X", &temp);
                data[i / 2] = temp & 0xff;
@@ -543,7 +543,7 @@ int param_gethex_to_eol(const char *line, int paramnum, uint8_t * data, int maxd
                        continue;
                }
                
-               if (isxdigit(line[indx])) {
+               if (isxdigit((unsigned char)line[indx])) {
                        buf[strlen(buf) + 1] = 0x00;
                        buf[strlen(buf)] = line[indx];
                } else {
@@ -620,7 +620,7 @@ int hextobinarray(char *target, char *source)
         else if (x >= 'A' && x <= 'F')
             x -= 'A' - 10;
         else {
-               printf("Discovered unknown character %c %d at idx %d of %s\n", x, x, source - start, start);
+               printf("Discovered unknown character %c %d at idx %tu of %s\n", x, x, source - start, start);
             return 0;
         }
         // output
Impressum, Datenschutz