aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2005-12-21 18:47:09 -0500
committerJunio C Hamano <junkio@cox.net>2005-12-21 17:05:09 -0800
commitf4a11066cfb70c49fddbca7f95aa0fedcee53cca (patch)
treecf52739b40edd18594f9b5dc3e7e6b6d5a4ebfa4 /sha1_file.c
parent8ac4838af428a2a32498b3e8d13295eb714654b4 (diff)
downloadgit-f4a11066cfb70c49fddbca7f95aa0fedcee53cca.tar.gz
git-f4a11066cfb70c49fddbca7f95aa0fedcee53cca.tar.xz
sanity check in add_packed_git()
add_packed_git() tries to get the pack SHA1 by parsing its name. It may access uninitialized memory for packs with short names. Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index fa22e9c71..d83d8240d 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -464,7 +464,7 @@ struct packed_git *add_packed_git(char *path, int path_len, int local)
p->pack_last_used = 0;
p->pack_use_cnt = 0;
p->pack_local = local;
- if (!get_sha1_hex(path + path_len - 40 - 4, sha1))
+ if ((path_len > 44) && !get_sha1_hex(path + path_len - 44, sha1))
memcpy(p->sha1, sha1, 20);
return p;
}