Fix an off-by-one bug in string/array handling which lead to memory overwrite

and follow-up assertion errors on at least ARM after r282257,
with nvp_magic being 0x6e7600:
Assertion failed: ((nvp)->nvp_magic == 0x6e7670), function nvpair_name, file .../subr_nvpair.c, line 713.

Sponsored by:	DARPA/AFRL
This commit is contained in:
Bjoern A. Zeeb 2015-05-02 08:31:16 +00:00
parent 1d29bfc149
commit 44aa151e1b

View File

@ -733,7 +733,7 @@ nvpair_allocv(const char *name, int type, uint64_t data, size_t datasize)
if (nvp != NULL) {
nvp->nvp_name = (char *)(nvp + 1);
memcpy(nvp->nvp_name, name, namelen);
nvp->nvp_name[namelen + 1] = '\0';
nvp->nvp_name[namelen] = '\0';
nvp->nvp_type = type;
nvp->nvp_data = data;
nvp->nvp_datasize = datasize;