From: Mike Hommey <mh@glandium.org>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/2] Fix random sha1 in error message in http-fetch and http-push
Date: Fri, 14 Dec 2007 22:18:01 +0100 [thread overview]
Message-ID: <1197667081-9909-2-git-send-email-mh@glandium.org> (raw)
In-Reply-To: <1197667081-9909-1-git-send-email-mh@glandium.org>
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 <mh@glandium.org>
---
Please note that this is already fixed in my strbuf patch for these files,
which had been applied in pu, but it seems to have disappeared from pu's
history. This also means the strbuf patch conflicts with this one. Please
tell me if you want a new strbuf patch made after this one.
http-push.c | 5 +++--
http-walker.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/http-push.c b/http-push.c
index fc60bfd..7f1d043 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 a3fb596..68b5108 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)
--
1.5.4.rc0.8.gbf4af-dirty
next prev parent reply other threads:[~2007-12-14 21:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 21:18 [PATCH 1/2] Fix some more memory leaks in http-push.c Mike Hommey
2007-12-14 21:18 ` Mike Hommey [this message]
2007-12-14 22:17 ` [PATCH 2/2] Fix random sha1 in error message in http-fetch and http-push Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1197667081-9909-2-git-send-email-mh@glandium.org \
--to=mh@glandium.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).