Code

Reject hexstring longer than 40-bytes in get_short_sha1()
authorpclouds@gmail.com <pclouds@gmail.com>
Thu, 19 Oct 2006 01:34:41 +0000 (08:34 +0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 19 Oct 2006 04:21:50 +0000 (21:21 -0700)
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>
sha1_name.c

index 9b226e3579b68fe8b59c7105bd926e3a0a70b0ad..6ffee22081aee3fc7b27b9ccc93c4c721652ec4b 100644 (file)
@@ -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);