[PATCH v3 20/22] resolve_ref(): also treat a too-long SHA1 as invalid
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Sep 15, 2011, 21:10 UTC
- Message-ID
- <1316121043-29367-21-git-send-email-mhagger@alum.mit.edu>
- In-Reply-To
- <1316121043-29367-1-git-send-email-mhagger@alum.mit.edu>
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> --- refs.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/refs.c b/refs.c index 2387f4e..0baa500 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; }
-- 1.7.6.8.gd2879