mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
Merge branch 'es/unpack-trees-oob-fix'
The code that tries to skip over the entries for the paths in a single directory using the cache-tree was not careful enough against corrupt index file. * es/unpack-trees-oob-fix: unpack-trees: watch for out-of-range index position
This commit is contained in:
commit
36da2a8635
|
@ -696,9 +696,11 @@ static int index_pos_by_traverse_info(struct name_entry *names,
|
|||
if (pos >= 0)
|
||||
BUG("This is a directory and should not exist in index");
|
||||
pos = -pos - 1;
|
||||
if (!starts_with(o->src_index->cache[pos]->name, name.buf) ||
|
||||
if (pos >= o->src_index->cache_nr ||
|
||||
!starts_with(o->src_index->cache[pos]->name, name.buf) ||
|
||||
(pos > 0 && starts_with(o->src_index->cache[pos-1]->name, name.buf)))
|
||||
BUG("pos must point at the first entry in this directory");
|
||||
BUG("pos %d doesn't point to the first entry of %s in index",
|
||||
pos, name.buf);
|
||||
strbuf_release(&name);
|
||||
return pos;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue