Skip to content

Commit

Permalink
Improve config file escape sanity checking
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Oct 11, 2005
1 parent 013f276 commit 5cbb401
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5cbb401

Please sign in to comment.