[2/6] qdev-property: Make bit property parsing stricter

Submitted by Stefan Hajnoczi on Jan. 27, 2012, 7:27 a.m.

Details

Message ID 1327649282-12431-3-git-send-email-stefanha@linux.vnet.ibm.com
State New
Headers show

Commit Message

Stefan Hajnoczi Jan. 27, 2012, 7:27 a.m.
From: Jan Kiszka <jan.kiszka@web.de>

By using strncasecmp, we allow for arbitrary characters after the
"on"/"off" string. Fix this by switching to strcasecmp.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 hw/qdev-properties.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Andreas Färber Jan. 27, 2012, 10:09 a.m.
Am 27.01.2012 08:27, schrieb Stefan Hajnoczi:
> From: Jan Kiszka <jan.kiszka@web.de>
> 
> By using strncasecmp, we allow for arbitrary characters after the
> "on"/"off" string. Fix this by switching to strcasecmp.
> 
> Reviewed-by: Andreas Färber <afaerber@suse.de>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

FWIW the ordering is wrong here. The tags are supposed to document the
patch flow: The patch was first signed off by the author (Jan), then
reviewed, then signed off by committers. Not first reviewed.

No need to respin but please keep in mind for the future.
(Yeah, did that wrong myself before.)

Andreas
Stefan Hajnoczi Feb. 5, 2012, 7:30 a.m.
On Fri, Jan 27, 2012 at 11:09:21AM +0100, Andreas Färber wrote:
> Am 27.01.2012 08:27, schrieb Stefan Hajnoczi:
> > From: Jan Kiszka <jan.kiszka@web.de>
> > 
> > By using strncasecmp, we allow for arbitrary characters after the
> > "on"/"off" string. Fix this by switching to strcasecmp.
> > 
> > Reviewed-by: Andreas Färber <afaerber@suse.de>
> > Reviewed-by: Markus Armbruster <armbru@redhat.com>
> > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> 
> FWIW the ordering is wrong here. The tags are supposed to document the
> patch flow: The patch was first signed off by the author (Jan), then
> reviewed, then signed off by committers. Not first reviewed.
> 
> No need to respin but please keep in mind for the future.
> (Yeah, did that wrong myself before.)

Okay, thanks.

Stefan

Patch hide | download patch | download mbox

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;