Skip to content

Commit

Permalink
Prevent git-upload-pack segfault if object cannot be found
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Worth <cworth@cworth.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
cworth-gh authored and Junio C Hamano committed Feb 18, 2006
1 parent eedf8f9 commit b5b1699
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,10 @@ static void prepare_packed_git_one(char *objdir, int local)
sprintf(path, "%s/pack", objdir);
len = strlen(path);
dir = opendir(path);
if (!dir)
if (!dir) {
fprintf(stderr, "unable to open object pack directory: %s: %s\n", path, strerror(errno));
return;
}
path[len++] = '/';
while ((de = readdir(dir)) != NULL) {
int namelen = strlen(de->d_name);
Expand Down
3 changes: 3 additions & 0 deletions upload-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ static int send_ref(const char *refname, const unsigned char *sha1)
static char *capabilities = "multi_ack";
struct object *o = parse_object(sha1);

if (!o)
die("git-upload-pack: cannot find object %s:", sha1_to_hex(sha1));

if (capabilities)
packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
0, capabilities);
Expand Down

0 comments on commit b5b1699

Please sign in to comment.