]> git.proxmox.com Git - qemu.git/commitdiff
qemu-socket: allow hostnames starting with a digit
authorJán Tomko <jtomko@redhat.com>
Mon, 3 Jun 2013 15:54:55 +0000 (17:54 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 18 Jun 2013 17:51:46 +0000 (12:51 -0500)
According to RFC 1123 [1], hostnames can start with a digit too.

[1] http://tools.ietf.org/html/rfc1123#page-13

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Cc: qemu-stable@nongnu.org
[Use strspn, not strcspn. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 391b7b9701ba3318e890ec0cba97a3c654bfa667)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
util/qemu-sockets.c

index fdd8dc460b5518bb0f4dbcdd6be99d108dfbcb5d..96eca2ad95b133d60d8072a34b286c9c152781a2 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "monitor/monitor.h"
 #include "qemu/sockets.h"
-#include "qemu-common.h" /* for qemu_isdigit */
 #include "qemu/main-loop.h"
 
 #ifndef AI_ADDRCONFIG
@@ -511,19 +510,15 @@ InetSocketAddress *inet_parse(const char *str, Error **errp)
             goto fail;
         }
         addr->ipv6 = addr->has_ipv6 = true;
-    } else if (qemu_isdigit(str[0])) {
-        /* IPv4 addr */
-        if (2 != sscanf(str, "%64[0-9.]:%32[^,]%n", host, port, &pos)) {
-            error_setg(errp, "error parsing IPv4 address '%s'", str);
-            goto fail;
-        }
-        addr->ipv4 = addr->has_ipv4 = true;
     } else {
-        /* hostname */
+        /* hostname or IPv4 addr */
         if (2 != sscanf(str, "%64[^:]:%32[^,]%n", host, port, &pos)) {
             error_setg(errp, "error parsing address '%s'", str);
             goto fail;
         }
+        if (host[strspn(host, "0123456789.")] == '\0') {
+            addr->ipv4 = addr->has_ipv4 = true;
+        }
     }
 
     addr->host = g_strdup(host);