]> 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@sury.org>
Fri, 17 Apr 2026 15:58:17 +0000 (17:58 +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.

(cherry picked from commit f7859247df222fa17a0ad52f8ce87816e06984ec)

bin/named/server.c

index c3c06d7d143ee8ae9613f50a458d53a84dc14106..72ab7c956a1233e45b5a5d0fe71724ad53c4ad94 100644 (file)
@@ -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,