git: f2206d2f94a4 - stable/13 - libsa: Fix a bug in nvlist creation

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 27 May 2022 13:20:48 UTC
The branch stable/13 has been updated by markj:

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

commit f2206d2f94a42f925db350a2bbab52091368ef95
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-05-20 14:15:00 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-05-27 13:14:58 +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
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit bcc3148c70c72cc409881e7a25e2bb053a39a0da)
---
 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);