From: Laszlo Ersek <lersek@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] fix Coverity scan SIGN_EXTENSION error
Date: Thu, 06 Jun 2013 20:52:06 +0200 [thread overview]
Message-ID: <51B0DA56.20504@redhat.com> (raw)
In-Reply-To: <1370531573-17974-1-git-send-email-kraxel@redhat.com>
On 06/06/13 17:12, Gerd Hoffmann wrote:
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/display/qxl-render.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c
> index f511a62..269b1a7 100644
> --- a/hw/display/qxl-render.c
> +++ b/hw/display/qxl-render.c
> @@ -199,7 +199,7 @@ static QEMUCursor *qxl_cursor(PCIQXLDevice *qxl, QXLCursor *cursor)
> c->hot_y = cursor->header.hot_spot_y;
> switch (cursor->header.type) {
> case SPICE_CURSOR_TYPE_ALPHA:
> - size = cursor->header.width * cursor->header.height * sizeof(uint32_t);
> + size = sizeof(uint32_t) * cursor->header.width * cursor->header.height;
> memcpy(c->data, cursor->chunk.data, size);
> if (qxl->debug > 2) {
> cursor_print_ascii_art(c, "qxl/alpha");
>
Right. "width" and "height" are both "uint16_t" (short unsigned) and
they are promoted to "int". The binding is then
(int * int) * size_t
int * size_t
size_t * size_t
size_t
By the time the product would be converted to size_t ("unsigned" or
"unsigned long" in practice, dependent on ILP32 or LP64), it may have
overflowed (undefined behavior for signed int).
The above changes it to
(size_t * int) * int
(size_t * size_t) * int
size_t * int
size_t * size_t
size_t
(BTW this is not order of evaluation, just how the types are determined
by operator binding.)
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
next prev parent reply other threads:[~2013-06-06 18:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-06 15:12 [Qemu-devel] [PATCH] fix Coverity scan SIGN_EXTENSION error Gerd Hoffmann
2013-06-06 18:52 ` Laszlo Ersek [this message]
2013-06-06 22:18 ` Andreas Färber
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=51B0DA56.20504@redhat.com \
--to=lersek@redhat.com \
--cc=armbru@redhat.com \
--cc=kraxel@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.