diff options
author | Theodore Ts'o <tytso@mit.edu> | 2017-01-31 15:30:28 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2017-01-31 15:30:28 -0500 |
commit | 89632b4b7dd631cdbe1f783b6c53a8c4639a089b (patch) | |
tree | ba3df9bcb9830887cc8517e21240f0b62235b121 /lib | |
parent | 7a82e706208f2eca52781d4970f90f8e1af9a25e (diff) | |
download | e2fsprogs-89632b4b7dd631cdbe1f783b6c53a8c4639a089b.tar.gz |
libsupport: improve how invalid hex strings are parsed as C strings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/support/cstring.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/support/cstring.c b/lib/support/cstring.c index 325047779..7965e9571 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++; |