Prevent git-upload-pack segfault if object cannot be found
Signed-off-by: Carl Worth <cworth@cworth.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:

committed by
Junio C Hamano

parent
eedf8f97e5
commit
b5b16990f8
@ -551,8 +551,10 @@ static void prepare_packed_git_one(char *objdir, int local)
|
|||||||
sprintf(path, "%s/pack", objdir);
|
sprintf(path, "%s/pack", objdir);
|
||||||
len = strlen(path);
|
len = strlen(path);
|
||||||
dir = opendir(path);
|
dir = opendir(path);
|
||||||
if (!dir)
|
if (!dir) {
|
||||||
|
fprintf(stderr, "unable to open object pack directory: %s: %s\n", path, strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
path[len++] = '/';
|
path[len++] = '/';
|
||||||
while ((de = readdir(dir)) != NULL) {
|
while ((de = readdir(dir)) != NULL) {
|
||||||
int namelen = strlen(de->d_name);
|
int namelen = strlen(de->d_name);
|
||||||
|
@ -216,6 +216,9 @@ static int send_ref(const char *refname, const unsigned char *sha1)
|
|||||||
static char *capabilities = "multi_ack";
|
static char *capabilities = "multi_ack";
|
||||||
struct object *o = parse_object(sha1);
|
struct object *o = parse_object(sha1);
|
||||||
|
|
||||||
|
if (!o)
|
||||||
|
die("git-upload-pack: cannot find object %s:", sha1_to_hex(sha1));
|
||||||
|
|
||||||
if (capabilities)
|
if (capabilities)
|
||||||
packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
|
packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
|
||||||
0, capabilities);
|
0, capabilities);
|
||||||
|
Reference in New Issue
Block a user