All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] qdev-property: Make bit property parsing stricter
Date: Sat, 21 Jan 2012 17:36:04 +0100	[thread overview]
Message-ID: <4F1AE974.2090401@suse.de> (raw)
In-Reply-To: <4F1AC0EB.3050304@web.de>

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 <jan.kiszka@siemens.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

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


WARNING: multiple messages have this Message-ID (diff)
From: "Andreas Färber" <afaerber@suse.de>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qdev-property: Make bit property parsing stricter
Date: Sat, 21 Jan 2012 17:36:04 +0100	[thread overview]
Message-ID: <4F1AE974.2090401@suse.de> (raw)
In-Reply-To: <4F1AC0EB.3050304@web.de>

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 <jan.kiszka@siemens.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

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

  reply	other threads:[~2012-01-21 16:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-21 13:43 [Qemu-trivial] [PATCH] qdev-property: Make bit property parsing stricter Jan Kiszka
2012-01-21 13:43 ` [Qemu-devel] " Jan Kiszka
2012-01-21 16:36 ` Andreas Färber [this message]
2012-01-21 16:36   ` Andreas Färber
2012-01-21 17:07   ` [Qemu-trivial] " Jan Kiszka
2012-01-21 17:07     ` Jan Kiszka
2012-01-24 12:05     ` [Qemu-trivial] " Markus Armbruster
2012-01-24 12:05       ` Markus Armbruster
2012-01-27  5:50 ` [Qemu-trivial] " Stefan Hajnoczi
2012-01-27  5:50   ` [Qemu-devel] " Stefan Hajnoczi

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=4F1AE974.2090401@suse.de \
    --to=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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.