From: Mike Hommey Date: Fri, 14 Dec 2007 21:18:01 +0000 (+0100) Subject: Fix random sha1 in error message in http-fetch and http-push X-Git-Tag: v1.5.4-rc1~60 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a096bb18af5b7214d9b87b64ae733d106eb96544;p=git.git Fix random sha1 in error message in http-fetch and http-push When a downloaded ref doesn't contain a sha1, the error message displays a random sha1 because of uninitialized memory. This happens when cloning a repository that is already a clone of another one, in which case refs/remotes/origin/HEAD is a symref. Signed-off-by: Mike Hommey Signed-off-by: Junio C Hamano --- diff --git a/http-push.c b/http-push.c index fc60bfd5f..c96e43da1 100644 --- a/http-push.c +++ b/http-push.c @@ -1149,9 +1149,10 @@ int fetch_ref(char *ref, unsigned char *sha1) return error("Unable to start request"); } + if (buffer.posn != 41) + return 1; hex[40] = '\0'; - get_sha1_hex(hex, sha1); - return 0; + return get_sha1_hex(hex, sha1); } static void one_remote_object(const char *hex) diff --git a/http-walker.c b/http-walker.c index a3fb59654..0faafbce6 100644 --- a/http-walker.c +++ b/http-walker.c @@ -986,9 +986,10 @@ static int fetch_ref(struct walker *walker, char *ref, unsigned char *sha1) return error("Unable to start request"); } + if (buffer.posn != 41) + return 1; hex[40] = '\0'; - get_sha1_hex(hex, sha1); - return 0; + return get_sha1_hex(hex, sha1); } static void cleanup(struct walker *walker)