• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From ffd290b4ab247f82722927ba9b21358daa16dbf1 Mon Sep 17 00:00:00 2001
2From: Rose <83477269+AtariDreams@users.noreply.github.com>
3Date: Thu, 1 Jun 2023 11:33:39 -0400
4Subject: [PATCH] Log result of httpGetHostname BEFORE closing the connection
5
6httpClose frees the memory of con->http. This is problematic because httpGetHostname then tries to access the memory it points to.
7
8We have to log the hostname first.
9
10Reference:https://github.com/OpenPrinting/cups/commit/9809947a959e18409dcf562a3466ef246cb90cb2
11Conflict:NA
12---
13 scheduler/client.c | 16 +++++++---------
14 1 file changed, 7 insertions(+), 9 deletions(-)
15
16diff --git a/scheduler/client.c b/scheduler/client.c
17index 91e441188c..327473a4d1 100644
18--- a/scheduler/client.c
19+++ b/scheduler/client.c
20@@ -193,13 +193,11 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
21    /*
22     * Can't have an unresolved IP address with double-lookups enabled...
23     */
24-
25-    httpClose(con->http);
26-
27     cupsdLogClient(con, CUPSD_LOG_WARN,
28-                    "Name lookup failed - connection from %s closed!",
29+                    "Name lookup failed - closing connection from %s!",
30                     httpGetHostname(con->http, NULL, 0));
31
32+    httpClose(con->http);
33     free(con);
34     return;
35   }
36@@ -235,11 +233,11 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
37       * with double-lookups enabled...
38       */
39
40-      httpClose(con->http);
41-
42       cupsdLogClient(con, CUPSD_LOG_WARN,
43-                      "IP lookup failed - connection from %s closed!",
44+                      "IP lookup failed - closing connection from %s!",
45                       httpGetHostname(con->http, NULL, 0));
46+
47+      httpClose(con->http);
48       free(con);
49       return;
50     }
51@@ -256,11 +254,11 @@ cupsdAcceptClient(cupsd_listener_t *lis)/* I - Listener socket */
52
53   if (!hosts_access(&wrap_req))
54   {
55-    httpClose(con->http);
56-
57     cupsdLogClient(con, CUPSD_LOG_WARN,
58                     "Connection from %s refused by /etc/hosts.allow and "
59 		    "/etc/hosts.deny rules.", httpGetHostname(con->http, NULL, 0));
60+
61+    httpClose(con->http);
62     free(con);
63     return;
64   }
65
66