]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
coverity fixes for my latest changes.
authoriceman1001 <iceman@iuse.se>
Tue, 22 Mar 2016 07:40:20 +0000 (08:40 +0100)
committericeman1001 <iceman@iuse.se>
Tue, 22 Mar 2016 07:40:20 +0000 (08:40 +0100)
Forgot some breaks in 7816 annotation, and  presco used an uninitalized char array.

armsrc/crapto1.h
client/cmdlfpresco.c
include/common.h

index 7ea6fa28f5b7af57ec7caa0c31fd912833a246f4..4d5fec0fa301cfdcb8cb9cfb5ed4428d58f59328 100644 (file)
@@ -70,9 +70,9 @@ static inline int parity(uint32_t x)
        return BIT(0x6996, x & 0xf);
 #else
        __asm__(        "movl %1, %%eax\n"
-               "mov %%ax, %%cx\n"
-               "shrl $0x10, %%eax\n"
-               "xor %%ax, %%cx\n"
+                               "mov %%ax, %%cx\n"
+                               "shrl $0x10, %%eax\n"
+                               "xor %%ax, %%cx\n"
                 "xor %%ch, %%cl\n"
                 "setpo %%al\n"
                 "movzx %%al, %0\n": "=r"(x) : "r"(x): "eax","ecx");
@@ -88,7 +88,7 @@ static inline int filter(uint32_t const x)
        f |= 0x3c8b0 >> (x >>  8 & 0xf) &  4;
        f |= 0x1e458 >> (x >> 12 & 0xf) &  2;
        f |= 0x0d938 >> (x >> 16 & 0xf) &  1;
-       return BIT(0xEC57E80A, f);
+       return BIT(0xEC57E80A, 0xf);
 }
 #ifdef __cplusplus
 }
index d6a324480c5e715016a47cd9d002179bc3bab9ad..51756c4f5ba1e5aa35a22444eeea432437ae2b17 100644 (file)
@@ -45,6 +45,8 @@ int GetWiegandFromPresco(const char *Cmd, uint32_t *sitecode, uint32_t *usercode
        uint8_t cmdp = 0;
        char id[11];
        int stringlen = 0;
+       memset(id, 0x00, sizeof(id));
+       
        while(param_getchar(Cmd, cmdp) != 0x00) {
                switch(param_getchar(Cmd, cmdp)) {
                        case 'h':
@@ -81,19 +83,19 @@ int GetWiegandFromPresco(const char *Cmd, uint32_t *sitecode, uint32_t *usercode
        if(errors) return -1;
 
        if (!hex) {
-       for (int index =0; index < strlen(id); ++index) {
-               
-               // Get value from number string.
-               if ( id[index] == '*' ) val = 10;
-               if ( id[index] == '#')  val = 11;               
-               if ( id[index] >= 0x30 && id[index] <= 0x39 )
-                       val = id[index] - 0x30;
-               
-                       *fullcode += val;
+               for (int index =0; index < strlen(id); ++index) {
                
-               // last digit is only added, not multipled.
-               if ( index < strlen(id)-1 ) 
-                               *fullcode *= 12;
+                       // Get value from number string.
+                       if ( id[index] == '*' ) val = 10;
+                       if ( id[index] == '#')  val = 11;               
+                       if ( id[index] >= 0x30 && id[index] <= 0x39 )
+                               val = id[index] - 0x30;
+                       
+                               *fullcode += val;
+                       
+                       // last digit is only added, not multipled.
+                       if ( index < strlen(id)-1 ) 
+                                       *fullcode *= 12;
                }
        }
 
index 3d063351059e81d8f9ccbe5c3ab23239c210a20f..2a67bd879c360c3c9363cfc26b098cdc697396d2 100644 (file)
@@ -29,6 +29,5 @@ typedef unsigned char byte_t;
 #ifndef ABS
 # define ABS(a) ( ((a)<0) ? -(a) : (a) )
 #endif
-
 #define RAMFUNC __attribute((long_call, section(".ramfunc")))
 #endif
Impressum, Datenschutz