summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2012-02-14 07:49:44 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-02-14 07:50:28 -0500
commit48f82b73c24d2486f10e588ebabce95873656d0e (patch)
treee69b10cdaf2a95cda88402a75c93a2f45013604f
parentb8c8811ea02d1d80faa0d0564cd1f464633a9c58 (diff)
downloadsssd-48f82b73c24d2486f10e588ebabce95873656d0e.tar.gz
sssd-48f82b73c24d2486f10e588ebabce95873656d0e.tar.xz
sssd-48f82b73c24d2486f10e588ebabce95873656d0e.zip
Ensure NULL-termination in get_uid_from_pid()
Coverity #12399
-rw-r--r--src/util/find_uid.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/util/find_uid.c b/src/util/find_uid.c
index 33c7c5ba7..f4156ce76 100644
--- a/src/util/find_uid.c
+++ b/src/util/find_uid.c
@@ -118,6 +118,9 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid)
}
}
+ /* Guarantee NULL-termination in case we read the full BUFSIZE somehow */
+ buf[BUFSIZE-1] = '\0';
+
ret = close(fd);
if (ret == -1) {
error = errno;