From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UosR1-0007XX-Is for qemu-devel@nongnu.org; Tue, 18 Jun 2013 05:42:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UosQz-00051u-QE for qemu-devel@nongnu.org; Tue, 18 Jun 2013 05:42:43 -0400 Received: from mail-ye0-f176.google.com ([209.85.213.176]:62490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UosQz-00051q-Kp for qemu-devel@nongnu.org; Tue, 18 Jun 2013 05:42:41 -0400 Received: by mail-ye0-f176.google.com with SMTP id m14so1258758yen.7 for ; Tue, 18 Jun 2013 02:42:41 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51C02B8A.2090709@redhat.com> Date: Tue, 18 Jun 2013 11:42:34 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-socket: allow hostnames starting with a digit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?SsOhbiBUb21rbw==?= Cc: qemu-devel@nongnu.org Il 03/06/2013 17:54, Ján Tomko ha scritto: > 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 > --- > util/qemu-sockets.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c > index fdd8dc4..727dafa 100644 > --- a/util/qemu-sockets.c > +++ b/util/qemu-sockets.c > @@ -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 (strcspn(host, "0123456789.") == 0) { I think what you want here is: if (host[strspn(host, "0123456789.")] == '\0') { Otherwise, you're still basically testing qemu_isdigit(str[0]) || str[0] == '.' Paolo > + addr->ipv4 = addr->has_ipv4 = true; > + } > } > > addr->host = g_strdup(host); >