@matheusbsbs / matheus-bagliano / commits / 34f3999206
Fork 0

grep: NUL terminate input from a file

Internally "git grep" runs regexec(3) that expects its input string to be NUL terminated. When searching inside blob data, read_sha1_file() automatically gives such a buffer, but builtin-grep.c forgot to put the NUL at the end, even though it allocated enough space for it. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jim Meyering committed Jan 18, 2010 at 22:55 UTC 34f3999206e8ea41b9e4cf48e30ab1149e01d8a5
1 file changed +1
builtin-grep.c
+1
@@ -207,6 +207,7 @@ static int grep_file(struct grep_opt *opt, const char *filename)
207 return 0;
208 }
209 close(i);
210 + data[sz] = 0;
211 if (opt->relative && opt->prefix_length)
212 filename = quote_path_relative(filename, -1, &buf, opt->prefix);
213 i = grep_buffer(opt, filename, data, sz);