From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Ján Tomko" <jtomko@redhat.com>, qemu-stable@nongnu.org
Subject: [Qemu-devel] [PATCH 1/2] qemu-socket: allow hostnames starting with a digit
Date: Tue, 18 Jun 2013 16:14:13 +0200 [thread overview]
Message-ID: <1371564854-2248-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1371564854-2248-1-git-send-email-pbonzini@redhat.com>
From: Ján Tomko <jtomko@redhat.com>
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>
---
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..96eca2a 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 (host[strspn(host, "0123456789.")] == '\0') {
+ addr->ipv4 = addr->has_ipv4 = true;
+ }
}
addr->host = g_strdup(host);
--
1.8.1.4
next prev parent reply other threads:[~2013-06-18 14:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 14:14 [Qemu-devel] [PULL 0/2] NBD changes for 2013-06-18 (including 1.5.1 patches) Paolo Bonzini
2013-06-18 14:14 ` Paolo Bonzini [this message]
2013-06-18 14:14 ` [Qemu-devel] [PATCH 2/2] nbd: strip braces from literal IPv6 address in URI Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2013-06-18 10:52 [Qemu-devel] [PULL 0/2] NBD changes for 2013-06-18 (including 1.5.1 patches) Paolo Bonzini
2013-06-18 10:52 ` [Qemu-devel] [PATCH 1/2] qemu-socket: allow hostnames starting with a digit Paolo Bonzini
2013-06-03 15:54 [Qemu-devel] [PATCH 0/2] Fix NBD hostname parsing issues Ján Tomko
2013-06-03 15:54 ` [Qemu-devel] [PATCH 1/2] qemu-socket: allow hostnames starting with a digit Ján Tomko
2013-06-18 9:42 ` Paolo Bonzini
2013-06-18 11:29 ` Ján Tomko
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=1371564854-2248-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=jtomko@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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).