From 89632b4b7dd631cdbe1f783b6c53a8c4639a089b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 31 Jan 2017 15:30:28 -0500 Subject: [PATCH] libsupport: improve how invalid hex strings are parsed as C strings Signed-off-by: Theodore Ts'o --- lib/support/cstring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/support/cstring.c b/lib/support/cstring.c index 3250477..7965e95 100644 --- a/lib/support/cstring.c +++ b/lib/support/cstring.c @@ -52,7 +52,7 @@ int parse_c_string(char *str) else if (ch >= 'A' && ch <= 'F') v = ch + 10 - 'A'; else { - ch = *from; + *to = 'x'; break; } from++; @@ -64,7 +64,8 @@ int parse_c_string(char *str) else if (ch >= 'A' && ch <= 'F') v = (v * 16) + (ch + 10 - 'A'); else { - ch = *from; + *to = 'x'; + from--; break; } from++; -- 1.8.3.1