git: bcc3148c70c7 - main - libsa: Fix a bug in nvlist creation

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 20 May 2022 14:36:33 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=bcc3148c70c72cc409881e7a25e2bb053a39a0da

commit bcc3148c70c72cc409881e7a25e2bb053a39a0da
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-05-20 14:15:00 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-05-20 14:34:43 +0000

    libsa: Fix a bug in nvlist creation
    
    When adding an entry to an nvlist, the data buffer might need to be
    resized.  When this happens, the XDR encoder's notion of the buffer size
    also needs to be updated, otherwise the operation may erroneously fail.
    
    Reviewed by:    tsoome, imp
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D35254
---
 stand/libsa/zfs/nvlist.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/stand/libsa/zfs/nvlist.c b/stand/libsa/zfs/nvlist.c
index ba994f97d40a..84a0edafe182 100644
--- a/stand/libsa/zfs/nvlist.c
+++ b/stand/libsa/zfs/nvlist.c
@@ -1213,6 +1213,7 @@ nvlist_add_common(nvlist_t *nvl, const char *name, data_type_t type,
 	nvl->nv_idx += sizeof(*hp);
 
 	xdr.xdr_buf = nvl->nv_data;
+	xdr.xdr_buf_size = nvl->nv_asize;
 	xdr.xdr_idx = nvl->nv_idx;
 
 	xdr.xdr_idx += xdr.xdr_putuint(&xdr, namelen);