Skip to contentSkip to conversation

segfault bug in internal git grep from next

PATCH Marco Roeland 1 participant 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hello!

I'm using the next branch as of commit 6a40327d242dac9f85c6d63c94d537b45ba86e89

A segfault occurs in using the new builtin grep when using it on a binary file, so no regular \n endings.

A testcase is the attached (if it survives the vger filters) "git.png" icon as it is used for example on the http://www.kernel.org/git website.

I tried the obvious, this is the line that gives the segfault:

builtin-grep.c +1 -1
index 09e3677..5d4f319 100644
@@ -121,7 +121,7 @@ static void compile_patterns(struct grep
 static char *end_of_line(char *cp, unsigned long *left)
 {
 	unsigned long l = *left;
-	while (l && *cp != '\n') {
+	while (l && *cp && *cp != '\n') {
 		l--;
 		cp++;
 	}

but it did not solve the problem. Unfortunately I have no time at the moment to investigate further, so just this report at the moment.

On a side-note it might be handy to add the icon to the main git repository and to use it in (new) test cases for git grep. Of course grepping in binary files is mostly not very useful, but lots of real-world repo's have some binaries.

Signature · 1 line
Marco Roeland
#1 lore raw

Re: segfault bug in internal git grep from next (fixed)

Quoted 4 lines · On Wednesday May 3rd 2006 Marco Roeland wrote:

I'm using the next branch as of commit 6a40327d242dac9f85c6d63c94d537b45ba86e89

A segfault occurs in using the new builtin grep when using it on a binary file, so no regular \n endings.

Fixed by Junio in commit 7ed36f56e33bd838d06521a37a916516397e9e8b.

I really use git grep a lot. It is very powerful, and the builtin version makes even more possible. Thanks very much,

Signature · 1 line
Marco Roeland