]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Log result of httpGetHostname BEFORE closing the connection
authorRose <83477269+AtariDreams@users.noreply.github.com>
Thu, 1 Jun 2023 15:33:39 +0000 (11:33 -0400)
committerRose <83477269+AtariDreams@users.noreply.github.com>
Tue, 6 Jun 2023 16:42:31 +0000 (12:42 -0400)
httpClose frees the memory of con->http. This is problematic because httpGetHostname then tries to access the memory it points to.

We have to log the hostname first.

scheduler/client.c

index 91e441188c9ed5d60fa7b82e876e938468b456b9..327473a4d1726746f0f23fcf57d3fb870ff47d74 100644 (file)
@@ -193,13 +193,11 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
    /*
     * Can't have an unresolved IP address with double-lookups enabled...
     */
-
-    httpClose(con->http);
-
     cupsdLogClient(con, CUPSD_LOG_WARN,
-                    "Name lookup failed - connection from %s closed!",
+                    "Name lookup failed - closing connection from %s!",
                     httpGetHostname(con->http, NULL, 0));
 
+    httpClose(con->http);
     free(con);
     return;
   }
@@ -235,11 +233,11 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
       * with double-lookups enabled...
       */
 
-      httpClose(con->http);
-
       cupsdLogClient(con, CUPSD_LOG_WARN,
-                      "IP lookup failed - connection from %s closed!",
+                      "IP lookup failed - closing connection from %s!",
                       httpGetHostname(con->http, NULL, 0));
+
+      httpClose(con->http);
       free(con);
       return;
     }
@@ -256,11 +254,11 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
 
   if (!hosts_access(&wrap_req))
   {
-    httpClose(con->http);
-
     cupsdLogClient(con, CUPSD_LOG_WARN,
                     "Connection from %s refused by /etc/hosts.allow and "
                    "/etc/hosts.deny rules.", httpGetHostname(con->http, NULL, 0));
+
+    httpClose(con->http);
     free(con);
     return;
   }