Skip to content

Commit

Permalink
An off-by-one bug found by valgrind
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pavel Roskin authored and Junio C Hamano committed Dec 21, 2005
1 parent 9470657 commit 6689f08
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ int main(int argc, char **argv)
if (len < 5 || strcmp(pack_name + len - 5, ".pack"))
die("packfile name '%s' does not end with '.pack'",
pack_name);
index_name_buf = xmalloc(len - 1);
index_name_buf = xmalloc(len);
memcpy(index_name_buf, pack_name, len - 5);
strcpy(index_name_buf + len - 5, ".idx");
index_name = index_name_buf;
Expand Down

0 comments on commit 6689f08

Please sign in to comment.