In open_binary_fd: when using buffer size for strl* and snprintf,
always use >= instead of > to avoid truncation. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D11474 MFC after: 3 days
This commit is contained in:
parent
0a8bc3079d
commit
07cd15e90e
@ -5300,14 +5300,14 @@ open_binary_fd(const char *argv0, bool search_in_path)
|
||||
fd = -1;
|
||||
errno = ENOENT;
|
||||
while ((pe = strsep(&pathenv, ":")) != NULL) {
|
||||
if (strlcpy(binpath, pe, sizeof(binpath)) >
|
||||
if (strlcpy(binpath, pe, sizeof(binpath)) >=
|
||||
sizeof(binpath))
|
||||
continue;
|
||||
if (binpath[0] != '\0' &&
|
||||
strlcat(binpath, "/", sizeof(binpath)) >
|
||||
strlcat(binpath, "/", sizeof(binpath)) >=
|
||||
sizeof(binpath))
|
||||
continue;
|
||||
if (strlcat(binpath, argv0, sizeof(binpath)) >
|
||||
if (strlcat(binpath, argv0, sizeof(binpath)) >=
|
||||
sizeof(binpath))
|
||||
continue;
|
||||
fd = open(binpath, O_RDONLY | O_CLOEXEC | O_VERIFY);
|
||||
|
Loading…
x
Reference in New Issue
Block a user