]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
altsvc: return error on dot-only name
authorDaniel Stenberg <daniel@haxx.se>
Mon, 13 Jan 2025 11:05:02 +0000 (12:05 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 13 Jan 2025 13:27:44 +0000 (14:27 +0100)
Because it is a trailing dot that otherwise leads to a zero length name.

Coverity CID 1638755.

Closes #15986

lib/altsvc.c

index 62f2c545fe55ed4a6fef3027143569b3f46a9abf..a77b1cf27966530f544047507e42818473a46091 100644 (file)
@@ -108,19 +108,20 @@ static struct altsvc *altsvc_createid(const char *srchost,
     return NULL;
   DEBUGASSERT(hlen);
   DEBUGASSERT(dlen);
-  if(!hlen || !dlen) {
+  if(!hlen || !dlen)
     /* bad input */
-    free(as);
-    return NULL;
-  }
+    goto error;
   if((hlen > 2) && srchost[0] == '[') {
     /* IPv6 address, strip off brackets */
     srchost++;
     hlen -= 2;
   }
-  else if(srchost[hlen - 1] == '.')
+  else if(srchost[hlen - 1] == '.') {
     /* strip off trailing dot */
     hlen--;
+    if(!hlen)
+      goto error;
+  }
   if((dlen > 2) && dsthost[0] == '[') {
     /* IPv6 address, strip off brackets */
     dsthost++;