aboutsummaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2011-09-15 23:10:41 +0200
committerJunio C Hamano <gitster@pobox.com>2011-10-05 13:45:31 -0700
commitf989fea0e0b47873de62a355f4766f03a88fb01b (patch)
tree6adaf0ef216fcff1b6bdb2c7291b58ed8e9ec917 /refs.c
parent629cd3ac6d081b43c8cdb045845be1fedbc89615 (diff)
downloadgit-f989fea0e0b47873de62a355f4766f03a88fb01b.tar.gz
git-f989fea0e0b47873de62a355f4766f03a88fb01b.tar.xz
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>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index 2387f4e73..0baa500cb 100644
--- a/refs.c
+++ b/refs.c
@@ -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;
}