From e2c0d989659c2b96a717f8bbdadbd981c6f6b8ca Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 9 Jun 2023 00:28:41 +0000 Subject: [PATCH] lib/roken/syslog.c: Initialize hostname to avoid DNS lookups. Previously, the hostname was initialized to `localhost'. If it was not cleared by init_syslog, init_logger_addr (via openlog) would query gethostbyname to find the IP address of `localhost', which will essentially always be 127.0.0.1. But if it was cleared by init_syslog, init_logger_addr would return 127.0.0.1 anyway. This way, it always returns 127.0.0.1 in the event of no init_syslog call, and avoids a DNS lookup. You can always force a DNS lookup by passing `localhost' to init_syslog explicitly, of course. I'm not sure if anything even uses this as a fallback in Heimdal, but let's avoid leaving a rake to step on. --- lib/roken/syslogc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/roken/syslogc.c b/lib/roken/syslogc.c index f4fb539a6..9687b1265 100644 --- a/lib/roken/syslogc.c +++ b/lib/roken/syslogc.c @@ -50,7 +50,7 @@ static SOCKADDR_IN syslog_hostaddr; static SOCKET syslog_socket = INVALID_SOCKET; static char local_hostname[ MAX_COMPUTERNAME_LENGTH + 1 ]; -static char syslog_hostname[ MAX_COMPUTERNAME_LENGTH + 1 ] = "localhost"; +static char syslog_hostname[ MAX_COMPUTERNAME_LENGTH + 1 ]; static unsigned short syslog_port = SYSLOG_PORT; static int datagramm_size;