Skip to content

Commit

Permalink
Reject hexstring longer than 40-bytes in get_short_sha1()
Browse files Browse the repository at this point in the history
Such a string can never be a valid object name.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
pclouds@gmail.com authored and Junio C Hamano committed Oct 19, 2006
1 parent 1a3b55c commit 8a83157
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static int get_short_sha1(const char *name, int len, unsigned char *sha1,
char canonical[40];
unsigned char res[20];

if (len < MINIMUM_ABBREV)
if (len < MINIMUM_ABBREV || len > 40)
return -1;
hashclr(res);
memset(canonical, 'x', 40);
Expand Down

0 comments on commit 8a83157

Please sign in to comment.