Loading block/nbd.c +10 −1 Original line number Diff line number Diff line Loading @@ -118,13 +118,22 @@ static int nbd_parse_uri(const char *filename, QDict *options) } qdict_put(options, "path", qstring_from_str(qp->p[0].value)); } else { QString *host; /* nbd[+tcp]://host[:port]/export */ if (!uri->server) { ret = -EINVAL; goto out; } qdict_put(options, "host", qstring_from_str(uri->server)); /* strip braces from literal IPv6 address */ if (uri->server[0] == '[') { host = qstring_from_substr(uri->server, 1, strlen(uri->server) - 2); } else { host = qstring_from_str(uri->server); } qdict_put(options, "host", host); if (uri->port) { char* port_str = g_strdup_printf("%d", uri->port); qdict_put(options, "port", qstring_from_str(port_str)); Loading util/qemu-sockets.c +4 −9 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); Loading Loading
block/nbd.c +10 −1 Original line number Diff line number Diff line Loading @@ -118,13 +118,22 @@ static int nbd_parse_uri(const char *filename, QDict *options) } qdict_put(options, "path", qstring_from_str(qp->p[0].value)); } else { QString *host; /* nbd[+tcp]://host[:port]/export */ if (!uri->server) { ret = -EINVAL; goto out; } qdict_put(options, "host", qstring_from_str(uri->server)); /* strip braces from literal IPv6 address */ if (uri->server[0] == '[') { host = qstring_from_substr(uri->server, 1, strlen(uri->server) - 2); } else { host = qstring_from_str(uri->server); } qdict_put(options, "host", host); if (uri->port) { char* port_str = g_strdup_printf("%d", uri->port); qdict_put(options, "port", qstring_from_str(port_str)); Loading
util/qemu-sockets.c +4 −9 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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); Loading