[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] include/hw: field 'offset' in struct Property s
From: |
Markus Armbruster |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Stumbled over this while throwing away old mail. Andreas, what do you
think?
Ildar Isaev <address@hidden> 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 <address@hidden>
> ---
> 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;
- Re: [Qemu-devel] [PATCH] include/hw: field 'offset' in struct Property should be ptrdiff_t as int causes overflow,
Markus Armbruster <=