From patchwork Mon Jun 3 15:54:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=A1n_Tomko?= X-Patchwork-Id: 248327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A44A52C0099 for ; Tue, 4 Jun 2013 01:58:39 +1000 (EST) Received: from localhost ([::1]:60614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjX9Z-0007yS-4K for incoming@patchwork.ozlabs.org; Mon, 03 Jun 2013 11:58:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjX7o-0005hg-FX for qemu-devel@nongnu.org; Mon, 03 Jun 2013 11:56:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjX7m-0004h9-Ip for qemu-devel@nongnu.org; Mon, 03 Jun 2013 11:56:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjX7m-0004gw-A1 for qemu-devel@nongnu.org; Mon, 03 Jun 2013 11:56:46 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r53Fujb2009899 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 3 Jun 2013 11:56:45 -0400 Received: from snc.brq.redhat.com ([10.34.248.82]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r53FuhAm031694; Mon, 3 Jun 2013 11:56:44 -0400 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2013 17:54:55 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id r53Fujb2009899 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 1/2] qemu-socket: allow hostnames starting with a digit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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) { + addr->ipv4 = addr->has_ipv4 = true; + } } addr->host = g_strdup(host);