]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Add checks in em4x50read to avoid segfaults in case loops go over the GraphTraceLen.
authoredouard@lafargue.name <edouard@lafargue.name@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 30 Jul 2009 15:24:03 +0000 (15:24 +0000)
committeredouard@lafargue.name <edouard@lafargue.name@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 30 Jul 2009 15:24:03 +0000 (15:24 +0000)
winsrc/command.cpp

index 44e0326b41c0d2b7cf2a221b9f7e2ee0d5504083..454fbab2417b1ddff306eb647fee98ce602ce862 100644 (file)
@@ -301,17 +301,19 @@ static void CmdEM4x50read(char *str)
        while(i < GraphTraceLen)\r
                {\r
                // measure from low to low\r
-               while(GraphBuffer[i] > low)\r
+               while((GraphBuffer[i] > low) && (i<GraphTraceLen))\r
                        ++i;\r
                start= i;\r
-               while(GraphBuffer[i] < high)\r
+               while((GraphBuffer[i] < high) && (i<GraphTraceLen))\r
                        ++i;\r
-               while(GraphBuffer[i] > low)\r
+               while((GraphBuffer[i] > low) && (i<GraphTraceLen))\r
                        ++i;\r
+               if (j>(MAX_GRAPH_TRACE_LEN/64)) {\r
+                       break;\r
+               }\r
                tmpbuff[j++]= i - start;\r
                }\r
 \r
-\r
        /* look for data start - should be 2 pairs of LW (pulses of 192,128) */\r
        start= -1;\r
        skip= 0;\r
@@ -1573,7 +1575,7 @@ static void CmdTIWrite(char *str)
        if (res == 2) c.ext3=0;\r
        if (res<2)\r
                PrintToScrollback("Please specify 2 or three hex strings, eg 0x1234 0x5678");\r
-       else \r
+       else\r
                SendCommand(&c, FALSE);\r
 }\r
 \r
Impressum, Datenschutz