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
This commit is contained in:
Mark Johnston 2022-05-20 10:15:00 -04:00
parent 4a3e51335e
commit bcc3148c70

View File

@ -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);