From: Markus Armbruster <armbru@redhat.com>
To: Ildar Isaev <ild@inbox.ru>
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org,
aliguori@amazon.com, "Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH] include/hw: field 'offset' in struct Property should be ptrdiff_t as int causes overflow
Date: Tue, 25 Aug 2015 16:17:43 +0200 [thread overview]
Message-ID: <87io83jvug.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <1425478186-18894-1-git-send-email-ild@inbox.ru> (Ildar Isaev's message of "Wed, 4 Mar 2015 17:09:46 +0300")
Stumbled over this while throwing away old mail. Andreas, what do you
think?
Ildar Isaev <ild@inbox.ru> writes:
> 'offset' field in struct Property is calculated as a diff between two pointers (hw/core/qdev-properties.c:802)
>
> arrayprop->prop.offset = eltptr - (void *)dev;
>
> If offset is declared as int, this subtraction can cause type overflow
> thus leading to the fall of the subsequent assert (hw/core/qdev-properties.c:803)
>
> assert(qdev_get_prop_ptr(dev, &arrayprop->prop) == eltptr);
>
> So ptrdiff_t should be used instead
>
> Signed-off-by: Ildar Isaev <ild@inbox.ru>
> ---
> include/hw/qdev-core.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 4e673f9..f0e2a73 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -224,7 +224,7 @@ struct BusState {
> struct Property {
> const char *name;
> PropertyInfo *info;
> - int offset;
> + ptrdiff_t offset;
> uint8_t bitnr;
> uint8_t qtype;
> int64_t defval;
next prev parent reply other threads:[~2015-08-25 14:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-04 14:09 [Qemu-devel] [PATCH] include/hw: field 'offset' in struct Property should be ptrdiff_t as int causes overflow Ildar Isaev
2015-08-25 14:17 ` Markus Armbruster [this message]
2015-08-25 14:32 ` Peter Maydell
2015-11-11 8:54 ` Markus Armbruster
2015-11-12 17:41 ` Andreas Färber
2015-11-13 18:32 ` John Snow
2015-11-13 18:36 ` Andreas Färber
2015-11-13 19:36 ` John Snow
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=87io83jvug.fsf@blackfin.pond.sub.org \
--to=armbru@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=ild@inbox.ru \
--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 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.