mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
pidfile test: guarantee nul termination of the read pid string
PR: 258701 Based on the submission by: sigsys@gmail.com MFC after: 1 week
This commit is contained in:
parent
d7cf1b262f
commit
364790beaf
1 changed files with 2 additions and 1 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue