From: Mark Wooding Date: Thu, 28 Sep 2017 01:02:03 +0000 (+0100) Subject: pkstream/pkstream.c (parseaddr): Allow address literals in brackets. X-Git-Tag: 1.5.0~41^2~45 X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/commitdiff_plain/8cc74f87d471ef4073f0cfef458929a90aaa698c pkstream/pkstream.c (parseaddr): Allow address literals in brackets. Actually, they don't have to be literals. Don't tell anyone. --- diff --git a/pkstream/pkstream.c b/pkstream/pkstream.c index cf66b3e4..f07c075b 100644 --- a/pkstream/pkstream.c +++ b/pkstream/pkstream.c @@ -378,9 +378,15 @@ static void parseaddr(const struct addrinfo *aihint, if (f&paf_parse) { alloc = xstrdup(host); - if ((sep = strchr(alloc, ':')) == 0) - die(1, "missing port number in address `%s'", host); - host = alloc; *sep = 0; svc = sep + 1; + if (alloc[0] != '[') { + if ((sep = strchr(alloc, ':')) == 0) + die(1, "missing port number in address `%s'", host); + host = alloc; *sep = 0; svc = sep + 1; + } else { + if ((sep = strchr(alloc, ']')) == 0 || sep[1] != ':') + die(1, "bad syntax in address `%s:'", host); + host = alloc + 1; *sep = 0; svc = sep + 2; + } } err = getaddrinfo(host, svc, aihint, ai_out);