From: Ondřej Surý Date: Fri, 17 Apr 2026 14:28:50 +0000 (+0200) Subject: Fix inverted gethostname() check in rndc status X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8213b31e1716d516aacf6623d91018fe550eabd0;p=thirdparty%2Fbind9.git Fix inverted gethostname() check in rndc status When named_os_gethostname() was replaced with raw gethostname(), the success/failure polarity was flipped: the fallback to "localhost" now runs on success and the hostname buffer is left uninitialized on failure. In the failure path, snprintf() then reads the uninitialized stack buffer, disclosing stack contents via the rndc status reply. (cherry picked from commit f7859247df222fa17a0ad52f8ce87816e06984ec) --- diff --git a/bin/named/server.c b/bin/named/server.c index c3c06d7d143..72ab7c956a1 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -12568,7 +12568,7 @@ named_server_status(named_server_t *server, isc_buffer_t **text) { cb); CHECK(putstr(text, line)); - if (gethostname(hostname, sizeof(hostname)) == 0) { + if (gethostname(hostname, sizeof(hostname)) != 0) { strlcpy(hostname, "localhost", sizeof(hostname)); } snprintf(line, sizeof(line), "running on %s: %s\n", hostname,