提交 d18dc3af 编写于 作者: M Markus Armbruster

tests/vhost-user-bridge: Fix misuse of isdigit()

vubr_set_host() passes char values to isdigit().  Undefined behavior
when the value is negative.

Fix by using qemu_isdigit() instead.
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Message-Id: <20190514180311.16028-3-armbru@redhat.com>
Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: NThomas Huth <thuth@redhat.com>
[Missing #include "qemu-common.h" fixed]
上级 b8c3511d
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu-common.h"
#include "qemu/atomic.h" #include "qemu/atomic.h"
#include "qemu/iov.h" #include "qemu/iov.h"
#include "standard-headers/linux/virtio_net.h" #include "standard-headers/linux/virtio_net.h"
...@@ -645,7 +646,7 @@ vubr_host_notifier_setup(VubrDev *dev) ...@@ -645,7 +646,7 @@ vubr_host_notifier_setup(VubrDev *dev)
static void static void
vubr_set_host(struct sockaddr_in *saddr, const char *host) vubr_set_host(struct sockaddr_in *saddr, const char *host)
{ {
if (isdigit(host[0])) { if (qemu_isdigit(host[0])) {
if (!inet_aton(host, &saddr->sin_addr)) { if (!inet_aton(host, &saddr->sin_addr)) {
fprintf(stderr, "inet_aton() failed.\n"); fprintf(stderr, "inet_aton() failed.\n");
exit(1); exit(1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册