Skip to content
Snippets Groups Projects
Commit 9d9c06b1 authored by Viktor Prutyanov's avatar Viktor Prutyanov Committed by Peter Maydell
Browse files

elf2dmp: check array bounds in pdb_get_file_size


Index in file_size array must be checked against num_files, because the
entries we are looking for may be absent in the PDB.

Fixes: Coverity CID 1521597
Signed-off-by: default avatarViktor Prutyanov <viktor@daynix.com>
Reviewed-by: default avatarAkihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20230930235317.11469-3-viktor@daynix.com
Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parent 8b01683e
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,10 @@
static uint32_t pdb_get_file_size(const struct pdb_reader *r, unsigned idx)
{
if (idx >= r->ds.toc->num_files) {
return 0;
}
return r->ds.toc->file_size[idx];
}
......@@ -159,16 +163,17 @@ static void *pdb_ds_read_file(struct pdb_reader* r, uint32_t file_number)
static int pdb_init_segments(struct pdb_reader *r)
{
char *segs;
unsigned stream_idx = r->segments;
segs = pdb_ds_read_file(r, stream_idx);
if (!segs) {
r->segs = pdb_ds_read_file(r, stream_idx);
if (!r->segs) {
return 1;
}
r->segs = segs;
r->segs_size = pdb_get_file_size(r, stream_idx);
if (!r->segs_size) {
return 1;
}
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment