summaryrefslogtreecommitdiff
path: root/rc/tools/python
diff options
context:
space:
mode:
authorChris Webb <chris@arachsys.com>2024-05-12 12:11:04 +0100
committerMaxime Coste <mawww@kakoune.org>2024-05-12 21:59:52 +1000
commit97a5d68adf48e99ac19dce21b32cecc7de9f0daa (patch)
tree937db08bdb172ce59c8dc0dc96e11d71bda8a6f3 /rc/tools/python
parent0e92b3fdefddbf81a008b3678faf4bf550be215c (diff)
Fix error handling when reading binary path from /proc
On Linux, Hurd, Cygwin, DragonFly BSD and Solaris/Illumos, Kakoune obtains a path to its binary by reading the appropriate /proc symlink target. readlink() can fail or it can fill the entire buffer, silently truncating the path if the buffer is too small. kak_assert() is compiled out in non-debug builds so we ignore a readlink() failure, corrupt the stack by writing to buffer[-1] then return a string from the uninitialised buffer. If readlink() succeeds and the binary path is sizeof(buffer) long, we write a \0 terminator beyond its end. If it is longer, we also truncate the path. Throw a fatal error on startup in all these unlikely failure cases.
Diffstat (limited to 'rc/tools/python')
0 files changed, 0 insertions, 0 deletions