]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix inverted gethostname() check in rndc status
authorOndřej Surý <ondrej@isc.org>
Fri, 17 Apr 2026 14:28:50 +0000 (16:28 +0200)
committerOndřej Surý <ondrej@isc.org>
Fri, 17 Apr 2026 15:51:48 +0000 (17:51 +0200)
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.

bin/named/server.c

index 2321ba6250dfa0eab15ec34d87f57dc1a628b604..bb706af60cb67b288845a18eee17a72ee9eb7c90 100644 (file)
@@ -11599,7 +11599,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,