comparison target-utils/simagent/stringarg.c @ 777:0cffc53991f9

simagent: bugfix in hex string arg parsing function
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Mar 2021 23:58:15 +0000
parents fac3176de18d
children
comparison
equal deleted inserted replaced
776:fac3176de18d 777:0cffc53991f9
28 arg++; 28 arg++;
29 if (!*arg) 29 if (!*arg)
30 break; 30 break;
31 if (!isxdigit(arg[0]) || !isxdigit(arg[1])) { 31 if (!isxdigit(arg[0]) || !isxdigit(arg[1])) {
32 printf("ERROR: invalid hex string input\n"); 32 printf("ERROR: invalid hex string input\n");
33 return; 33 return(-1);
34 } 34 }
35 if (count >= maxlen) { 35 if (count >= maxlen) {
36 printf("ERROR: hex string input is too long\n"); 36 printf("ERROR: hex string input is too long\n");
37 return; 37 return(-1);
38 } 38 }
39 buf[count++] = (decode_hex_digit(arg[0]) << 4) | 39 buf[count++] = (decode_hex_digit(arg[0]) << 4) |
40 decode_hex_digit(arg[1]); 40 decode_hex_digit(arg[1]);
41 arg += 2;
41 } 42 }
42 return count; 43 return count;
43 } 44 }