summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2011-12-16 10:45:46 -0500
committerStephen Gallagher <sgallagh@redhat.com>2011-12-19 11:38:35 -0500
commit05113318e280904f2a1ce3721b8d6504afd7e7df (patch)
tree37ae0bf55b2cf64cc212d4fb0d3bba6182dcff53 /src
parent49a5e85dc4deec84ce73862750b73dc764638d3d (diff)
downloadsssd-05113318e280904f2a1ce3721b8d6504afd7e7df.tar.gz
sssd-05113318e280904f2a1ce3721b8d6504afd7e7df.tar.xz
sssd-05113318e280904f2a1ce3721b8d6504afd7e7df.zip
Reorder pidfile() function to guarantee NULL-termination
Coverity 12400
Diffstat (limited to 'src')
-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 0c9501b1f..a9be4be1a 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 */