From: Peter Maydell Date: Mon, 20 Sep 2021 08:54:32 +0000 (+0100) Subject: elf2dmp: Fail cleanly if PDB file specifies zero block_size X-Git-Tag: v6.2.0-rc0~91^2~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f015cbb546387e1132a15c29e6afacec4a6d2910;p=thirdparty%2Fqemu.git elf2dmp: Fail cleanly if PDB file specifies zero block_size Coverity points out that if the PDB file we're trying to read has a header specifying a block_size of zero then we will end up trying to divide by zero in pdb_ds_read_file(). Check for this and fail cleanly instead. Fixes: Coverity CID 1458869 Signed-off-by: Peter Maydell Reviewed-by: Viktor Prutyanov Signed-off-by: Philippe Mathieu-Daudé Tested-by: Viktor Prutyanov Message-id: 20210910170656.366592-3-philmd@redhat.com Message-Id: <20210901143910.17112-3-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c index b3a65470680..adcfa7e154c 100644 --- a/contrib/elf2dmp/pdb.c +++ b/contrib/elf2dmp/pdb.c @@ -215,6 +215,10 @@ out_symbols: static int pdb_reader_ds_init(struct pdb_reader *r, PDB_DS_HEADER *hdr) { + if (hdr->block_size == 0) { + return 1; + } + memset(r->file_used, 0, sizeof(r->file_used)); r->ds.header = hdr; r->ds.toc = pdb_ds_read(hdr, (uint32_t *)((uint8_t *)hdr +