Skip to content

Commit

Permalink
Fix random sha1 in error message in http-fetch and http-push
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Mike Hommey authored and Junio C Hamano committed Dec 15, 2007
1 parent 3b683b9 commit a096bb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions http-walker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a096bb1

Please sign in to comment.