diff options
author | Stefan Grundmann <sg2342@googlemail.com> | 2021-08-18 16:26:29 +0000 |
---|---|---|
committer | Mariusz Zaborski <oshogbo@FreeBSD.org> | 2021-09-13 19:21:14 +0000 |
commit | e673ac3ffbfb2e300d02a47f984df63bd20a6578 (patch) | |
tree | 8d1d5f9459c07eaf62629145cc8b13dc23ebf5ec | |
parent | 93d6fa53c9951563be3081a347cc4dc1917ad452 (diff) | |
download | src-e673ac3ffbfb2e300d02a47f984df63bd20a6578.tar.gz src-e673ac3ffbfb2e300d02a47f984df63bd20a6578.zip |
libnv: Fix array unpack endianness logic
When a nvlist(9) is converted into a binary buffer by nvlist_pack(9),
the host endianness is encoded in the nvlist_header of the binary
buffer. The nvlist_unpack(9) function converts a given binary buffer
to an nvlist. In the conversion process the endianness encoded in the
nvlist_header is evaluated and -- should the encoded endianness differ
from the endianess of the decoding host -- endianness conversion is
applied to nvlist_header and nvpair_header elements as well as
to some nvpair values.
In 2015 @oshogbo extended libnv with array support (in 347a39b).
The unpacking code misses the possible need to convert the endianness
of the nvph_nitems element of nvpair_headers.
The patch (re)enables libnv to unpack nvlists regardless of the
endianness of the packing host.
Pull Request: https://github.com/freebsd/freebsd-src/pull/528
-rw-r--r-- | sys/contrib/libnv/bsd_nvpair.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/contrib/libnv/bsd_nvpair.c b/sys/contrib/libnv/bsd_nvpair.c index 6405dcd1c516..00eee223fe92 100644 --- a/sys/contrib/libnv/bsd_nvpair.c +++ b/sys/contrib/libnv/bsd_nvpair.c @@ -661,11 +661,13 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const unsigned char *ptr, if (!isbe) { nvphdr.nvph_namesize = le16toh(nvphdr.nvph_namesize); nvphdr.nvph_datasize = le64toh(nvphdr.nvph_datasize); + nvphdr.nvph_nitems = le64toh(nvphdr.nvph_nitems); } #else if (isbe) { nvphdr.nvph_namesize = be16toh(nvphdr.nvph_namesize); nvphdr.nvph_datasize = be64toh(nvphdr.nvph_datasize); + nvphdr.nvph_nitems = be64toh(nvphdr.nvph_nitems); } #endif |