FIX: coverty scan, overflow in "hf 14a raw", added an extra len check against USB_CMD_DATA_SIZE
if(topazmode)
c.arg[0] |= ISO14A_TOPAZMODE;
-
+
// Max buffer is USB_CMD_DATA_SIZE
+ datalen = (datalen > USB_CMD_DATA_SIZE) ? USB_CMD_DATA_SIZE : datalen;
+
c.arg[1] = (datalen & 0xFFFF) | (numbits << 16);
memcpy(c.d.asBytes,data,datalen);
uint16_t traceLen = resp.arg[1];\r
len = resp.arg[2];\r
\r
- if (res == 0) return 0; // we are done\r
+ if (res == 0) {\r
+ free(buf);\r
+ return 0; // we are done\r
+ }\r
\r
if (res == 1) { // there is (more) data to be transferred\r
if (pckNum == 0) { // first packet, (re)allocate necessary buffer\r