FreeCalypso > hg > freecalypso-hwlab
diff uicc/hexstr.c @ 158:65a2a96386cd
fc-uicc-tool: hex string parsing with min and max length,
matching fc-simtool
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Feb 2021 04:00:27 +0000 |
parents | baf5bd698764 |
children |
line wrap: on
line diff
--- a/uicc/hexstr.c Sun Feb 07 02:47:51 2021 +0000 +++ b/uicc/hexstr.c Sun Feb 07 04:00:27 2021 +0000 @@ -20,10 +20,10 @@ return(-1); } -decode_hex_data_from_string(arg, databuf, maxlen) +decode_hex_data_from_string(arg, databuf, minlen, maxlen) char *arg; u_char *databuf; - unsigned maxlen; + unsigned minlen, maxlen; { unsigned count; @@ -37,15 +37,15 @@ return(-1); } if (count >= maxlen) { - fprintf(stderr, "error: hex input data is too long\n"); + fprintf(stderr, "error: hex string is too long\n"); return(-1); } databuf[count] = (decode_hex_digit(arg[0]) << 4) | decode_hex_digit(arg[1]); arg += 2; } - if (!count) { - fprintf(stderr, "error: empty hex string argument\n"); + if (count < minlen) { + fprintf(stderr, "error: hex string is too short\n"); return(-1); } return(count);