]> 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ý (GitLab job 7225096) <ondrej@isc.org>
Fri, 17 Apr 2026 15:53:06 +0000 (15:53 +0000)
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 4644f097ebb037960775ac84336a2b4f734e1435..df9acea28f731a5c5b46a7463f81a68974f5a889 100644 (file)
@@ -12660,7 +12660,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,