]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix IPv6 address encoding in the Host: header (Issue #903)
authorMichael R Sweet <msweet@msweet.org>
Fri, 1 Mar 2024 16:52:38 +0000 (11:52 -0500)
committerMichael R Sweet <msweet@msweet.org>
Fri, 1 Mar 2024 16:52:38 +0000 (11:52 -0500)
CHANGES.md
cups/http.c

index 1d2fb73fa012afe4ba9da90bf3a1ece56bb6dbc2..59c508ce87dc2ec77d5e486a7fc688ec4c406896 100644 (file)
@@ -19,7 +19,8 @@ Changes in CUPS v2.5b1 (TBA)
 - Updated CUPS to require ZLIB.
 - Updated CUPS to require support for `poll` API.
 - Updated `cupsArray` APIs to support modern naming and types.
-- Updated `cups_enum_dests()` timeout for listing available IPP printers (Issue #751)
+- Updated `cups_enum_dests()` timeout for listing available IPP printers
+  (Issue #751)
 - Updated `httpAddrConnect2()` to handle `POLLHUP` together with `POLLIN` or
   `POLLOUT` (Issue #839)
 - Fixed use-after-free in `cupsdAcceptClient()` when we log warning during error
@@ -30,7 +31,8 @@ Changes in CUPS v2.5b1 (TBA)
   (Issue #423)
 - Fixed extensive looping in scheduler (Issue #604)
 - Fixed printing multiple files on specific printers (Issue #643)
-- Fixed printing of jobs with job name longer than 255 chars on older printers (Issue #644)
+- Fixed printing of jobs with job name longer than 255 chars on older printers
+  (Issue #644)
 - Fixed segfault in `cupsGetNamedDest()` when trying to get default printer, but
   the default printer is not set (Issue #719)
 - Fixed ready media support for iOS 17+ (Issue #738)
@@ -44,15 +46,17 @@ Changes in CUPS v2.5b1 (TBA)
 - Fixed memory leak when creating color profiles (Issue #814)
 - Fixed crash in `scan_ps()` if incoming argument is NULL (Issue #831)
 - Fixed setting job state reasons for successful jobs (Issue #832)
-- Fixed infinite loop in IPP backend if hostname is IP address with Kerberos (Issue #838)
+- Fixed infinite loop in IPP backend if hostname is IP address with Kerberos
+  (Issue #838)
 - Fixed crash in `ppdEmitString()` if there is no record for page size `Custom`
   (Issue #849)
-- Fixed reporting `media-source-supported` when sharing printer which has numbers as strings
-  instead of keywords as `InputSlot` values (Issue #859)
+- Fixed reporting `media-source-supported` when sharing printer which has
+  numbers as strings instead of keywords as `InputSlot` values (Issue #859)
 - Fixed IPP backend to support the "print-scaling" option with IPP printers
   (Issue #862)
 - Fixed Oki 407 freeze when printing larger jobs (Issue #877)
 - Fixed checking for required attributes during PPD generation (Issue #890)
+- Fixed encoding of IPv6 addresses in HTTP requests (Issue #903)
 - Removed hash support for SHA2-512-224 and SHA2-512-256.
 - Removed `mantohtml` script for generating html pages (use
   `https://www.msweet.org/mantohtml/`)
index c154412b179941eea3b78115e47a2c008f598d20..744c1dba2ef0e7eeb0b18fd800071d127bb87846 100644 (file)
@@ -3620,7 +3620,31 @@ http_create(
   http->version  = HTTP_VERSION_1_1;
 
   if (host)
-    cupsCopyString(http->hostname, host, sizeof(http->hostname));
+  {
+    DEBUG_printf("5http_create: host=\"%s\"", host);
+
+    if (!strncmp(host, "fe80::", 6))
+    {
+      // IPv6 link local address, convert to IPvFuture format...
+      char     *zoneid;                // Pointer to zoneid separator
+
+      snprintf(http->hostname, sizeof(http->hostname), "[v1.%s]", host);
+      if ((zoneid = strchr(http->hostname, '%')) != NULL)
+        *zoneid = '+';
+    }
+    else if (isxdigit(host[0]) && isxdigit(host[1]) && isxdigit(host[2]) && isxdigit(host[3]) && host[4] == ':')
+    {
+      // IPv6 address, convert to URI format...
+      snprintf(http->hostname, sizeof(http->hostname), "[%s]", host);
+    }
+    else
+    {
+      // Not an IPv6 numeric address...
+      cupsCopyString(http->hostname, host, sizeof(http->hostname));
+    }
+
+    DEBUG_printf("5http_create: http->hostname=\"%s\"", http->hostname);
+  }
 
   if (port == 443)                     // Always use encryption for https
     http->encryption = HTTP_ENCRYPTION_ALWAYS;