qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] elf2dmp: Fail cleanly if PDB file specifies zero block_size
Date: Thu, 9 Sep 2021 00:28:28 +0300	[thread overview]
Message-ID: <20210909002828.5261796c@192.168.1.7> (raw)
In-Reply-To: <20210901143910.17112-3-peter.maydell@linaro.org>

Hi,

On Wed,  1 Sep 2021 15:39:10 +0100
Peter Maydell <peter.maydell@linaro.org> wrote:

> 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 <peter.maydell@linaro.org>
> ---
>  contrib/elf2dmp/pdb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> 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 +

Looks good.

Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>

-- 
Viktor Prutyanov


      reply	other threads:[~2021-09-08 21:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 14:39 [PATCH 0/2] elf2dmp: Fix minor Coverity nits Peter Maydell
2021-09-01 14:39 ` [PATCH 1/2] elf2dmp: Check curl_easy_setopt() return value Peter Maydell
2021-09-01 15:25   ` Philippe Mathieu-Daudé
2021-09-08 21:43     ` Viktor Prutyanov
2021-09-08 23:25       ` Philippe Mathieu-Daudé
2021-09-01 14:39 ` [PATCH 2/2] elf2dmp: Fail cleanly if PDB file specifies zero block_size Peter Maydell
2021-09-08 21:28   ` Viktor Prutyanov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909002828.5261796c@192.168.1.7 \
    --to=viktor.prutyanov@phystech.edu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).