@matheusbsbs / matheus-bagliano / commits / 6689f08735
Fork 0

An off-by-one bug found by valgrind

Insufficient memory is allocated in index-pack.c to hold the *.idx name. One more byte should be allocated to hold the terminating 0. Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Pavel Roskin committed Dec 21, 2005 at 15:35 UTC 6689f08735d08a057f8d6f91af98b04960afa517
1 file changed +1 -1
index-pack.c
+1 -1
@@ -440,7 +440,7 @@ int main(int argc, char **argv)
440 if (len < 5 || strcmp(pack_name + len - 5, ".pack"))
441 die("packfile name '%s' does not end with '.pack'",
442 pack_name);
443 - index_name_buf = xmalloc(len - 1);
443 + index_name_buf = xmalloc(len);
444 memcpy(index_name_buf, pack_name, len - 5);
445 strcpy(index_name_buf + len - 5, ".idx");
446 index_name = index_name_buf;