From: Theodore Ts'o Date: Tue, 31 Jan 2017 20:30:28 +0000 (-0500) Subject: libsupport: improve how invalid hex strings are parsed as C strings X-Git-Tag: v1.43.4~13 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=89632b4b7dd631cdbe1f783b6c53a8c4639a089b;p=tools%2Fe2fsprogs.git libsupport: improve how invalid hex strings are parsed as C strings Signed-off-by: Theodore Ts'o --- 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++;