From 450b6ba5f3785d18095a56eb9fbd5bbdaad43d1a Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Thu, 1 Jun 2023 11:33:39 -0400 Subject: [PATCH] Log result of httpGetHostname BEFORE closing the connection 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 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scheduler/client.c b/scheduler/client.c index 236355a..d76e1e0 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -203,13 +203,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; } @@ -245,11 +243,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; } @@ -266,11 +264,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; } -- 2.33.0