aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/qdev-properties.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 0deb378009..a4545f7969 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -164,6 +164,10 @@ static int parse_hex8(DeviceState *dev, Property *prop, const char *str)
uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
char *end;
+ if (str[0] != '0' || str[1] != 'x') {
+ return -EINVAL;
+ }
+
*ptr = strtoul(str, &end, 16);
if ((*end != '\0') || (end == str)) {
return -EINVAL;
@@ -369,6 +373,10 @@ static int parse_hex32(DeviceState *dev, Property *prop, const char *str)
uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
char *end;
+ if (str[0] != '0' || str[1] != 'x') {
+ return -EINVAL;
+ }
+
*ptr = strtoul(str, &end, 16);
if ((*end != '\0') || (end == str)) {
return -EINVAL;
@@ -456,6 +464,10 @@ static int parse_hex64(DeviceState *dev, Property *prop, const char *str)
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
char *end;
+ if (str[0] != '0' || str[1] != 'x') {
+ return -EINVAL;
+ }
+
*ptr = strtoull(str, &end, 16);
if ((*end != '\0') || (end == str)) {
return -EINVAL;