Skip to content

Commit

Permalink
resolve_ref(): also treat a too-long SHA1 as invalid
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Oct 5, 2011
1 parent 629cd3a commit f989fea
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f989fea

Please sign in to comment.