1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-10 20:26:14 +02:00

resolve_ref(): also treat a too-long SHA1 as invalid

If the SHA1 in a reference file is not terminated by a space or
end-of-file, consider it malformed and emit a warning.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael Haggerty 2011-09-15 23:10:41 +02:00 committed by Junio C Hamano
parent 629cd3ac6d
commit f989fea0e0

3
refs.c
View File

@ -593,7 +593,8 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
if (flag)
*flag |= REF_ISSYMREF;
}
if (get_sha1_hex(buffer, sha1)) {
/* Please note that FETCH_HEAD has a second line containing other data. */
if (get_sha1_hex(buffer, sha1) || (buffer[40] != '\0' && !isspace(buffer[40]))) {
warning("reference in %s is formatted incorrectly", path);
return NULL;
}