diff mbox series

[mmc-utils,3/5] Fix parsing of character in to_binstr()

Message ID 20181218143601.24413-4-michael.heimpold@i2se.com (mailing list archive)
State New, archived
Headers show
Series Various fixes for mmc-utils | expand

Commit Message

Michael Heimpold Dec. 18, 2018, 2:35 p.m. UTC
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>
---
 lsmmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lsmmc.c b/lsmmc.c
index a53bc57..e64117c 100644
--- a/lsmmc.c
+++ b/lsmmc.c
@@ -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++;
 	}