Fix parsing of character in to_binstr()

When a hex-digit > 'a' or 'A' is read, we have to add an offset of 10
to access the valid symbol in our mapping table.

Signed-off-by: Michael Heimpold <michael.heimpold@i2se.com>
Cc: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Chris Ball <chris@printf.net>
This commit is contained in:
Michael Heimpold authored and Chris Ball committed 2019-10-04 20:47:27 -04:00
1 parent de27fd9752
commit c19c7694d2
1 file changed
+2 -2
+2 -2
View File
@@ -386,9 +386,9 @@ char *to_binstr(char *hexstr)
if (isdigit(*hexstr))
strcat(binstr, bindigits[*hexstr - '0']);
else if (islower(*hexstr))
strcat(binstr, bindigits[*hexstr - 'a']);
strcat(binstr, bindigits[*hexstr - 'a' + 10]);
else
strcat(binstr, bindigits[*hexstr - 'A']);
strcat(binstr, bindigits[*hexstr - 'A' + 10]);
hexstr++;
}