From 5cbb401dbaff5fd810a85b84333cb0c22d264f36 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 11 Oct 2005 15:24:11 -0700 Subject: [PATCH] Improve config file escape sanity checking 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 Signed-off-by: Junio C Hamano --- config.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index f3c4fa42a..510456ceb 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; -- 2.30.2