From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Laurent Vivier" <laurent@vivier.eu>,
"Michael Roth" <mdroth@linux.vnet.ibm.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH 1/9] hw/core/qdev-properties: Use qemu_strtol() in set_mac() handler
Date: Fri, 13 Mar 2020 19:45:59 +0100 [thread overview]
Message-ID: <20200313184607.11792-2-philmd@redhat.com> (raw)
In-Reply-To: <20200313184607.11792-1-philmd@redhat.com>
Replace strtol() by qemu_strtol() so checkpatch.pl won't complain
if we move this code later.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/core/qdev-properties.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 59380ed761..48e4c98cf0 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1,4 +1,5 @@
#include "qemu/osdep.h"
+#include "qemu/cutils.h"
#include "net/net.h"
#include "hw/qdev-properties.h"
#include "qapi/error.h"
@@ -532,7 +533,8 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
MACAddr *mac = qdev_get_prop_ptr(dev, prop);
Error *local_err = NULL;
int i, pos;
- char *str, *p;
+ char *str;
+ const char *p;
if (dev->realized) {
qdev_prop_set_after_realize(dev, name, errp);
@@ -546,6 +548,8 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
}
for (i = 0, pos = 0; i < 6; i++, pos += 3) {
+ long val;
+
if (!qemu_isxdigit(str[pos])) {
goto inval;
}
@@ -561,7 +565,10 @@ static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque,
goto inval;
}
}
- mac->a[i] = strtol(str+pos, &p, 16);
+ if (qemu_strtol(str + pos, &p, 16, &val) < 0 || val > 0xff) {
+ goto inval;
+ }
+ mac->a[i] = val;
}
g_free(str);
return;
--
2.21.1
next prev parent reply other threads:[~2020-03-13 18:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 18:45 [PATCH 0/9] user-mode: Prune build dependencies (part 3) Philippe Mathieu-Daudé
2020-03-13 18:45 ` Philippe Mathieu-Daudé [this message]
2020-03-15 21:25 ` [PATCH 1/9] hw/core/qdev-properties: Use qemu_strtol() in set_mac() handler Richard Henderson
2020-03-15 22:28 ` Philippe Mathieu-Daudé
2020-03-13 18:46 ` [PATCH 2/9] hw/core/qdev-properties: Use qemu_strtoul() in set_pci_host_devaddr() Philippe Mathieu-Daudé
2020-03-15 21:43 ` Richard Henderson
2020-03-13 18:46 ` [PATCH 3/9] hw/core/qdev-properties: Fix code style Philippe Mathieu-Daudé
2020-03-15 22:24 ` Richard Henderson
2020-03-13 18:46 ` [PATCH 4/9] hw/core/qdev-properties: Export enum-related functions Philippe Mathieu-Daudé
2020-03-15 22:26 ` Richard Henderson
2020-03-13 18:46 ` [PATCH 5/9] hw/core/qdev-properties: Export qdev_prop_enum Philippe Mathieu-Daudé
2020-03-15 22:26 ` Richard Henderson
2020-03-13 18:46 ` [PATCH 6/9] hw/core/qdev-properties: Export some integer-related functions Philippe Mathieu-Daudé
2020-03-15 22:27 ` Richard Henderson
2020-03-13 18:46 ` [PATCH 7/9] hw/core/qdev-properties: Extract system-mode specific properties Philippe Mathieu-Daudé
2020-03-15 22:30 ` Richard Henderson
2020-03-13 18:46 ` [PATCH 8/9] hw/core: Add qdev stub for user-mode Philippe Mathieu-Daudé
2020-03-14 9:46 ` Philippe Mathieu-Daudé
2020-03-14 10:49 ` Philippe Mathieu-Daudé
2020-03-14 10:57 ` Paolo Bonzini
2020-03-15 23:29 ` Philippe Mathieu-Daudé
2020-03-13 18:46 ` [PATCH 9/9] qapi: Restrict code generated " Philippe Mathieu-Daudé
2020-03-15 22:31 ` Richard Henderson
2020-03-15 21:38 ` [PATCH 0/9] user-mode: Prune build dependencies (part 3) no-reply
2020-03-15 21:42 ` no-reply
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=20200313184607.11792-2-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=laurent@vivier.eu \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).