Improve config file escape sanity checking
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:08
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:08
Subsystem:
the rest · Maintainer:
Linus Torvalds
I had meant to disallow unknown escape characters in the config file parser, but instead an unknown escaped character would silently pass through as itself. That's correct for some cases (notably '\' itself), but wasn't correct in general. This fixes it, and makes the parser write a nice error message if the config file contains bogus escaped characters. Signed-off-by: Linus Torvalds <torvalds@osdl.org> ---
diff --git a/config.c b/config.c
index f3c4fa4..510456c 100644
--- a/config.c
+++ b/config.c@@ -64,7 +64,12 @@ static char *parse_value(void) case 'n': c = '\n'; break; - return NULL; + /* Some characters escape as themselves */ + case '\\': case '"': + break; + /* Reject unknown escape sequences */ + default: + return NULL; } value[len++] = c; continue;