提交 c455d17c 编写于 作者: J Jan Kiszka 提交者: Stefan Hajnoczi

qdev-property: Make bit property parsing stricter

By using strncasecmp, we allow for arbitrary characters after the
"on"/"off" string. Fix this by switching to strcasecmp.
Reviewed-by: NAndreas Färber <afaerber@suse.de>
Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
上级 36945d95
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册