[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH] qdev-property: Make bit property
From: |
Andreas Färber |
Subject: |
Re: [Qemu-trivial] [Qemu-devel] [PATCH] qdev-property: Make bit property parsing stricter |
Date: |
Sat, 21 Jan 2012 17:36:04 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 |
Am 21.01.2012 14:43, schrieb Jan Kiszka:
> By using strncasecmp, we allow for arbitrary characters after the
> "on"/"off" string. Fix this by switching to strcasecmp.
>
> Signed-off-by: Jan Kiszka <address@hidden>
Reviewed-by: Andreas Färber <address@hidden>
An alternative might be to increase the char count by one. For a const
char* parameter I see the responsibility for nul-terminating at the
caller though, so this seems right. Did you check all callers?
Andreas
> ---
> hw/qdev-properties.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index 02f0dae..ea3b2df 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -40,9 +40,9 @@ static void qdev_prop_cpy(DeviceState *dev, Property
> *props, void *src)
> /* Bit */
> static int parse_bit(DeviceState *dev, Property *prop, const char *str)
> {
> - if (!strncasecmp(str, "on", 2))
> + if (!strcasecmp(str, "on"))
> bit_prop_set(dev, prop, true);
> - else if (!strncasecmp(str, "off", 3))
> + else if (!strcasecmp(str, "off"))
> bit_prop_set(dev, prop, false);
> else
> 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