]> git.ipfire.org Git - thirdparty/pdns.git/commit
Don't read potentially uninitalized memory if gethostname() failed 9115/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 27 Apr 2020 14:48:16 +0000 (16:48 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 13 May 2020 09:26:20 +0000 (11:26 +0200)
commitae005c9f673606ef13c5efc3931fd6f400b8d5aa
tree6cf60fb03b723bf73c536c9a54d9fa5d60bff1dc
parent0b9169fc395cd76b45f329aeab4624db28debe34
Don't read potentially uninitalized memory if gethostname() failed

If the buffer is smaller than `HOST_NAME_MAX` (64 on Linux but up to
255 bytes in POSIX, which FreeBSD, MacOS etc honor) gethostname()
might return -1 without null-terminating the buffer, causing an
out-of-bounds read.
As we look for the first '.' using `strchr()`, replacing it with a
null byte, we also have a one-byte out-of-bounds write which might
result in a crash or, albeit very unlikely, arbitrary code execution.

(cherry picked from commit aac6348d56f6f3fdba9dd2455ef06081da507c14)
pdns/rec-carbon.cc