From 43abd12a37ea1c410ffb923b9cadfbf0f6ea6e6a Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 14 Feb 2012 07:49:44 -0500 Subject: Ensure NULL-termination in get_uid_from_pid() Coverity #12399 --- src/util/find_uid.c | 3 +++ 1 file changed, 3 insertions(+) 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; -- cgit