]> git.ipfire.org Git - thirdparty/pdns.git/commit
Don't read potentially uninitalized memory if gethostname() failed 9116/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:18:05 +0000 (11:18 +0200)
commit39b266dfa726ae7685af07a7a354c04548a479b7
tree646c84960dd317a4dbc6dad9cf748636d5550d6b
parent921f6160829a0c0abc8034d6aa26a825701b9d57
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)
(cherry picked from commit be93bc7da4caddc5a6c84fa7b42e82592e9add49)
pdns/rec-carbon.cc