зеркало из https://github.com/microsoft/git.git
Merge branch 'rs/sha1-file-plug-fallback-base-leak'
A leak in a codepath to read from a packed object in (rare) cases has been plugged. * rs/sha1-file-plug-fallback-base-leak: sha1_file: release fallback base's memory in unpack_entry()
This commit is contained in:
Коммит
82682e218a
|
@ -2606,6 +2606,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
|
||||||
while (delta_stack_nr) {
|
while (delta_stack_nr) {
|
||||||
void *delta_data;
|
void *delta_data;
|
||||||
void *base = data;
|
void *base = data;
|
||||||
|
void *external_base = NULL;
|
||||||
unsigned long delta_size, base_size = size;
|
unsigned long delta_size, base_size = size;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -2632,6 +2633,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
|
||||||
p->pack_name);
|
p->pack_name);
|
||||||
mark_bad_packed_object(p, base_sha1);
|
mark_bad_packed_object(p, base_sha1);
|
||||||
base = read_object(base_sha1, &type, &base_size);
|
base = read_object(base_sha1, &type, &base_size);
|
||||||
|
external_base = base;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2650,6 +2652,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
|
||||||
"at offset %"PRIuMAX" from %s",
|
"at offset %"PRIuMAX" from %s",
|
||||||
(uintmax_t)curpos, p->pack_name);
|
(uintmax_t)curpos, p->pack_name);
|
||||||
data = NULL;
|
data = NULL;
|
||||||
|
free(external_base);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2669,6 +2672,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
|
||||||
error("failed to apply delta");
|
error("failed to apply delta");
|
||||||
|
|
||||||
free(delta_data);
|
free(delta_data);
|
||||||
|
free(external_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
*final_type = type;
|
*final_type = type;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче