Received: from eggs.gnu.org ([140.186.70.92]:40021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rodx8-00045t-4B for qemu-devel@nongnu.org; Sat, 21 Jan 2012 11:38:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rodx6-000863-JI for qemu-devel@nongnu.org; Sat, 21 Jan 2012 11:38:06 -0500 Message-ID: <4F1AE974.2090401@suse.de> Date: Sat, 21 Jan 2012 17:36:04 +0100 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <4F1AC0EB.3050304@web.de> In-Reply-To: <4F1AC0EB.3050304@web.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qdev-property: Make bit property parsing stricter List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: qemu-trivial , qemu-devel , Markus Armbruster 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. >=20 > Signed-off-by: Jan Kiszka Reviewed-by: Andreas F=E4rber 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(-) >=20 > 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; --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg