diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2011-09-15 23:10:31 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-10-05 13:45:30 -0700 |
commit | 7bb2bf8e5cc47f7731c9c012ecc943b14f99ee5a (patch) | |
tree | 23d0c7e9d321e98401be80fcd50eb0c33bea3fc2 /refs.c | |
parent | a40e6fb67a4aed2d5ffde5792bf7f1996d9666e1 (diff) | |
download | git-7bb2bf8e5cc47f7731c9c012ecc943b14f99ee5a.tar.gz |
resolve_ref(): explicitly fail if a symlink is not readable
Previously the failure came later, after a few steps in which the
length was treated like the actual length of a string. Even though
the old code gave the same answers, it was somewhat misleading.
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.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -518,6 +518,8 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int * /* Follow "normalized" - ie "refs/.." symlinks by hand */ if (S_ISLNK(st.st_mode)) { len = readlink(path, buffer, sizeof(buffer)-1); + if (len < 0) + return NULL; if (len >= 5 && !memcmp("refs/", buffer, 5)) { buffer[len] = 0; strcpy(ref_buffer, buffer); |