pkstream/pkstream.c (parseaddr): Allow address literals in brackets.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 28 Sep 2017 01:02:03 +0000 (02:02 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 28 Jun 2018 23:24:00 +0000 (00:24 +0100)
Actually, they don't have to be literals.  Don't tell anyone.

pkstream/pkstream.c

index cf66b3e..f07c075 100644 (file)
@@ -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);