git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Improve config file escape sanity checking
@ 2005-10-11 19:13 Linus Torvalds
  0 siblings, 0 replies; only message in thread
From: Linus Torvalds @ 2005-10-11 19:13 UTC (permalink / raw)
  To: Junio C Hamano, Git Mailing List


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;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-11 19:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-11 19:13 Improve config file escape sanity checking Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).