diff options
author | Pavel Roskin <proski@gnu.org> | 2005-12-21 15:35:48 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-12-21 13:00:31 -0800 |
commit | 6689f08735d08a057f8d6f91af98b04960afa517 (patch) | |
tree | 28c007b949e0956b712f0900b690c9b12db99ccb /index-pack.c | |
parent | 9470657ad0d0472e3e3c2e352334f60e7bd777c1 (diff) | |
download | git-6689f08735d08a057f8d6f91af98b04960afa517.tar.gz git-6689f08735d08a057f8d6f91af98b04960afa517.tar.xz |
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>
Diffstat (limited to 'index-pack.c')
-rw-r--r-- | index-pack.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/index-pack.c b/index-pack.c index 785fe71a6..d4ce3af58 100644 --- a/index-pack.c +++ b/index-pack.c @@ -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; |