Skip to content

Commit

Permalink
read_object_with_reference: don't read beyond the buffer
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Martin Koegler authored and Junio C Hamano committed Feb 19, 2008
1 parent e5fc9a0 commit 50974ec
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,8 @@ void *read_object_with_reference(const unsigned char *sha1,
}
ref_length = strlen(ref_type);

if (memcmp(buffer, ref_type, ref_length) ||
if (ref_length + 40 > isize ||
memcmp(buffer, ref_type, ref_length) ||
get_sha1_hex((char *) buffer + ref_length, actual_sha1)) {
free(buffer);
return NULL;
Expand Down

0 comments on commit 50974ec

Please sign in to comment.