From owner-dev-commits-src-all@freebsd.org Mon Sep 13 19:25:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 691E96A84DA; Mon, 13 Sep 2021 19:25:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H7bzt1ZxJz4pKp; Mon, 13 Sep 2021 19:25:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 37D365088; Mon, 13 Sep 2021 19:25:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18DJPjw1019146; Mon, 13 Sep 2021 19:25:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18DJPjOA019145; Mon, 13 Sep 2021 19:25:45 GMT (envelope-from git) Date: Mon, 13 Sep 2021 19:25:45 GMT Message-Id: <202109131925.18DJPjOA019145@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mariusz Zaborski Subject: git: e673ac3ffbfb - main - libnv: Fix array unpack endianness logic MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e673ac3ffbfb2e300d02a47f984df63bd20a6578 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2021 19:25:46 -0000 The branch main has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=e673ac3ffbfb2e300d02a47f984df63bd20a6578 commit e673ac3ffbfb2e300d02a47f984df63bd20a6578 Author: Stefan Grundmann AuthorDate: 2021-08-18 16:26:29 +0000 Commit: Mariusz Zaborski CommitDate: 2021-09-13 19:21:14 +0000 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 --- sys/contrib/libnv/bsd_nvpair.c | 2 ++ 1 file changed, 2 insertions(+) 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