qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ildar Isaev <ild@inbox.ru>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Ildar Isaev <ild@inbox.ru>,
	aliguori@amazon.com
Subject: [Qemu-devel] [PATCH] include/hw: field 'offset' in struct Property should be ptrdiff_t as int causes overflow
Date: Wed,  4 Mar 2015 17:09:46 +0300	[thread overview]
Message-ID: <1425478186-18894-1-git-send-email-ild@inbox.ru> (raw)

'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;
-- 
1.9.3

             reply	other threads:[~2015-03-04 14:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 14:09 Ildar Isaev [this message]
2015-08-25 14:17 ` [Qemu-devel] [PATCH] include/hw: field 'offset' in struct Property should be ptrdiff_t as int causes overflow Markus Armbruster
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=1425478186-18894-1-git-send-email-ild@inbox.ru \
    --to=ild@inbox.ru \
    --cc=aliguori@amazon.com \
    --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).