Commit c19c7694 authored by Michael Heimpold's avatar Michael Heimpold Committed by Chris Ball
Browse files

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: default avatarMichael Heimpold <michael.heimpold@i2se.com>
Cc: Michael Heimpold <mhei@heimpold.de>
Reviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
Signed-off-by: default avatarChris Ball <chris@printf.net>
parent de27fd97
...@@ -386,9 +386,9 @@ char *to_binstr(char *hexstr) ...@@ -386,9 +386,9 @@ char *to_binstr(char *hexstr)
if (isdigit(*hexstr)) if (isdigit(*hexstr))
strcat(binstr, bindigits[*hexstr - '0']); strcat(binstr, bindigits[*hexstr - '0']);
else if (islower(*hexstr)) else if (islower(*hexstr))
strcat(binstr, bindigits[*hexstr - 'a']); strcat(binstr, bindigits[*hexstr - 'a' + 10]);
else else
strcat(binstr, bindigits[*hexstr - 'A']); strcat(binstr, bindigits[*hexstr - 'A' + 10]);
hexstr++; hexstr++;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment