Skip to content

Commit b6a1261

Browse files
committed
Merge branch 'jk/fast-import-fixes'
With sufficiently long refnames, fast-import could have overflown an on-stack buffer. * jk/fast-import-fixes: fast-import: fix buffer overflow in dump_tags fast-import: clean up pack_data pointer in end_packfile
2 parents 88e7dff + c252785 commit b6a1261

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fast-import.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -946,10 +946,12 @@ static void unkeep_all_packs(void)
946946

947947
static void end_packfile(void)
948948
{
949-
struct packed_git *old_p = pack_data, *new_p;
949+
if (!pack_data)
950+
return;
950951

951952
clear_delta_base_cache();
952953
if (object_count) {
954+
struct packed_git *new_p;
953955
unsigned char cur_pack_sha1[20];
954956
char *idx_name;
955957
int i;
@@ -991,10 +993,11 @@ static void end_packfile(void)
991993
pack_id++;
992994
}
993995
else {
994-
close(old_p->pack_fd);
995-
unlink_or_warn(old_p->pack_name);
996+
close(pack_data->pack_fd);
997+
unlink_or_warn(pack_data->pack_name);
996998
}
997-
free(old_p);
999+
free(pack_data);
1000+
pack_data = NULL;
9981001

9991002
/* We can't carry a delta across packfiles. */
10001003
strbuf_release(&last_blob.data);

0 commit comments

Comments
 (0)