]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix a memory reallocation bug in HTTP header value expansion
authorMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 18 Apr 2019 11:52:54 +0000 (07:52 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 18 Apr 2019 11:52:54 +0000 (07:52 -0400)
(rdar://problem/50000749)

CHANGES.md
cups/http.c

index ae874c2b5b8b60ea8ad823b129cb3b88ce669402..f673ea2220ac09a29ad9a3e0ef6d0aef8d2aa1eb 100644 (file)
@@ -1,4 +1,4 @@
-CHANGES - 2.3b8 - 2019-04-15
+CHANGES - 2.3b8 - 2019-04-18
 ============================
 
 
@@ -9,6 +9,8 @@ Changes in CUPS v2.3b8
 - The lpadmin command would hang with a bad PPD file (rdar://41495016)
 - Fixed a potential crash bug in cups-driverd (rdar://46625579)
 - Fixed a performance regression with large PPDs (rdar://47040759)
+- Fixed a memory reallocation bug in HTTP header value expansion
+  (rdar://problem/50000749)
 - Restored minimal support for the `Emulators` keyword in PPD files to allow
   old Samsung printer drivers to continue to work (Issue #5562)
 - The scheduler did not encode octetString values like "job-password" correctly
index df9b7bdd66fde6cdee93cf81b96335effeedc12d..ff8f6918f8bebe403c7706bb4d0553717d4cd201 100644 (file)
@@ -3644,7 +3644,15 @@ http_add_field(http_t       *http,       /* I - HTTP connection */
 
     char       *combined;              /* New value string */
 
-    if ((combined = realloc(http->fields[field], total + 1)) != NULL)
+    if (http->fields[field] == http->_fields[field])
+    {
+      if ((combined = malloc(total + 1)) != NULL)
+      {
+       http->fields[field] = combined;
+       snprintf(combined, total + 1, "%s, %s", http->_fields[field], value);
+      }
+    }
+    else if ((combined = realloc(http->fields[field], total + 1)) != NULL)
     {
       http->fields[field] = combined;
       strlcat(combined, ", ", total + 1);