mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-09 19:52:31 +00:00
utils: lockfile: avoid stack overflow for lockfile buffer
There appears to have been some change on openSUSE (likely some new hardening flags for builds, or some glibc hardening) such that incorrect buffer handling results in a segfault even if the buffer is never overflowed. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
committed by
Jari Sundell
parent
d067bd802e
commit
92bec88d09
@@ -98,7 +98,8 @@ Lockfile::try_lock() {
|
||||
int pos = ::gethostname(buf, 255);
|
||||
|
||||
if (pos == 0) {
|
||||
::snprintf(buf + std::strlen(buf), 255, ":+%i\n", ::getpid());
|
||||
ssize_t len = std::strlen(buf);
|
||||
::snprintf(buf + len, 255 - len, ":+%i\n", ::getpid());
|
||||
int __UNUSED result = ::write(fd, buf, std::strlen(buf));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user