]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libsupport: improve how invalid hex strings are parsed as C strings
authorTheodore Ts'o <tytso@mit.edu>
Tue, 31 Jan 2017 20:30:28 +0000 (15:30 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 31 Jan 2017 20:30:28 +0000 (15:30 -0500)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/support/cstring.c

index 325047779ebe13f73fdd621dfd6932f292b521e6..7965e9571c6ecc9386b58167432ec20745996d5e 100644 (file)
@@ -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++;