Date: Fri, 1 Oct 2021 00:33:32 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 288a4784012c - stable/13 - pidfile test: guarantee nul termination of the read pid string Message-ID: <202110010033.1910XW9C095945@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=288a4784012ca3f2b2c2cb46e67d9c65cd55b5e0 commit 288a4784012ca3f2b2c2cb46e67d9c65cd55b5e0 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-09-24 03:12:20 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-10-01 00:32:22 +0000 pidfile test: guarantee nul termination of the read pid string PR: 258701 (cherry picked from commit 364790beafec707ca3e334683e4030684d829be2) --- lib/libutil/tests/pidfile_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libutil/tests/pidfile_test.c b/lib/libutil/tests/pidfile_test.c index 9e516c35273c..9bfa6754ce54 100644 --- a/lib/libutil/tests/pidfile_test.c +++ b/lib/libutil/tests/pidfile_test.c @@ -286,7 +286,8 @@ test_pidfile_relative(void) fd = open(path, O_RDONLY); if (fd < 0) return (strerror(errno)); - if (read(fd, pid, sizeof(pid)) < 0) + memset(pid, 0, sizeof(pid)); + if (read(fd, pid, sizeof(pid) - 1) < 0) return (strerror(errno)); if (atoi(pid) != getpid()) return ("pid mismatch");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110010033.1910XW9C095945>