mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-25 07:49:18 +00:00
libnv: verify that string is null terminated
During unpacking, we ensure that we do not read beyond the declared size. However, unpack uses a function that copies null-terminated strings. Prior to this commit, if the last string was not null-terminated, it could result in copying data into a buffer smaller than the allocated size. Security: FreeBSD-24:09.libnv Security: CVE-2024-45288 Security: CAP-03 Reported by: Synacktiv Sponsored by: The Alpha-Omega Project Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46138
This commit is contained in:
parent
36fa90dbde
commit
3aaaca1b51
@ -988,6 +988,10 @@ nvpair_unpack_string_array(bool isbe __unused, nvpair_t *nvp,
|
||||
for (ii = 0; ii < nvp->nvp_nitems; ii++) {
|
||||
len = strnlen(tmp, size - 1) + 1;
|
||||
size -= len;
|
||||
if (tmp[len - 1] != '\0') {
|
||||
ERRNO_SET(EINVAL);
|
||||
return (NULL);
|
||||
}
|
||||
if (size < 0) {
|
||||
ERRNO_SET(EINVAL);
|
||||
return (NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user