diff --git a/src/utils/lockfile.cc b/src/utils/lockfile.cc index 76e4b8fb..ba320313 100644 --- a/src/utils/lockfile.cc +++ b/src/utils/lockfile.cc @@ -75,8 +75,9 @@ Lockfile::try_lock() { int pos = ::gethostname(buf, 255); if (pos == 0) { - ::snprintf(buf + std::strlen(buf), 255, ":+%i\n", ::getpid()); - ssize_t __attribute__((unused)) result = ::write(fd, buf, std::strlen(buf)); + ssize_t len = std::strlen(buf); + ::snprintf(buf + len, 255 - len, ":+%i\n", ::getpid()); + int __attribute__((unused)) result = ::write(fd, buf, std::strlen(buf)); } ::close(fd);