summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/server.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/util/server.c b/src/util/server.c
index 0c9501b1..a9be4be1 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -117,9 +117,6 @@ int pidfile(const char *path, const char *name)
fd = open(file, O_RDONLY, 0644);
err = errno;
if (fd != -1) {
-
- pid_str[pidlen] = '\0';
-
len = 0;
while ((ret = read(fd, pid_str + len, pidlen - len)) != 0) {
if (ret == -1) {
@@ -141,6 +138,9 @@ int pidfile(const char *path, const char *name)
}
}
+ /* Ensure NULL-termination */
+ pid_str[len] = '\0';
+
if (ret == 0) {
/* let's check the pid */