From d7b0a09316fe8dcb62ad247dbbb45c3c777667ad Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Thu, 18 Oct 2007 22:02:35 +0200 Subject: attr: fix segfault in gitattributes parsing code git may segfault if gitattributes contains an invalid entry. A test is added to t0020 that triggers the segfault. The parsing code is fixed to avoid the crash. Signed-off-by: Steffen Prohaska Signed-off-by: Shawn O. Pearce --- attr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'attr.c') diff --git a/attr.c b/attr.c index 129399310..6e82507be 100644 --- a/attr.c +++ b/attr.c @@ -214,8 +214,11 @@ static struct match_attr *parse_attr_line(const char *line, const char *src, num_attr = 0; cp = name + namelen; cp = cp + strspn(cp, blank); - while (*cp) + while (*cp) { cp = parse_attr(src, lineno, cp, &num_attr, res); + if (!cp) + return NULL; + } if (pass) break; res = xcalloc(1, -- cgit v1.2.1