From: "Andreas Färber" <afaerber@suse.de>
To: Hannes Reinecke <hare@suse.de>
Cc: Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCHv2] qdev: Validate hex properties
Date: Wed, 27 Nov 2013 10:35:01 +0100 [thread overview]
Message-ID: <5295BCC5.4010500@suse.de> (raw)
In-Reply-To: <1385538775-4208-1-git-send-email-hare@suse.de>
Am 27.11.2013 08:52, schrieb Hannes Reinecke:
> strtoul(l) might overflow, in which case it'll return '-1' and set
> the appropriate error code. So update the calls to strtoul(l) when
> parsing hex properties to avoid silent overflows.
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Eric Blake <eblake@redhat.com>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
> hw/core/qdev-properties.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index dc8ae69..5a94c04 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -198,7 +198,10 @@ static int parse_hex8(DeviceState *dev, Property *prop, const char *str)
> return -EINVAL;
> }
>
> + errno = 0;
> *ptr = strtoul(str, &end, 16);
> + if (errno)
> + return -errno;
> if ((*end != '\0') || (end == str)) {
> return -EINVAL;
> }
Thanks, this seems to match the requested logic. But please run
checkpatch.pl and add the missing braces. I'll queue it then.
Please add Cc: qemu-stable@nongnu.org to the commit message while at it
since this seems a bug fix that spans multiple releases.
Regards,
Andreas
> @@ -329,7 +332,10 @@ static int parse_hex32(DeviceState *dev, Property *prop, const char *str)
> return -EINVAL;
> }
>
> + errno = 0;
> *ptr = strtoul(str, &end, 16);
> + if (errno)
> + return -errno;
> if ((*end != '\0') || (end == str)) {
> return -EINVAL;
> }
> @@ -396,7 +402,10 @@ static int parse_hex64(DeviceState *dev, Property *prop, const char *str)
> return -EINVAL;
> }
>
> + errno = 0;
> *ptr = strtoull(str, &end, 16);
> + if (errno)
> + return -errno;
> if ((*end != '\0') || (end == str)) {
> return -EINVAL;
> }
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2013-11-27 9:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-27 7:52 [Qemu-devel] [PATCHv2] qdev: Validate hex properties Hannes Reinecke
2013-11-27 9:35 ` Andreas Färber [this message]
2013-11-27 12:48 ` Eric Blake
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=5295BCC5.4010500@suse.de \
--to=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=hare@suse.de \
--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).