Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions module/nvpair/nvpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -2980,7 +2980,7 @@ nvpair_native_embedded_array(nvstream_t *nvs, nvpair_t *nvp)
return (nvs_embedded_nvl_array(nvs, nvp, NULL));
}

static void
static int
nvpair_native_string_array(nvstream_t *nvs, nvpair_t *nvp)
{
switch (nvs->nvs_op) {
Expand All @@ -2999,15 +2999,32 @@ nvpair_native_string_array(nvstream_t *nvs, nvpair_t *nvp)
case NVS_OP_DECODE: {
char **strp = (void *)NVP_VALUE(nvp);
char *buf = ((char *)strp + NVP_NELEM(nvp) * sizeof (uint64_t));
char *end = (char *)nvp + nvp->nvp_size;
int i;

for (i = 0; i < NVP_NELEM(nvp); i++) {
size_t max, len;

if (buf >= end)
return (EFAULT);

max = (size_t)(end - buf);
len = strnlen(buf, max);

/*
* The nvpair is corrupt if any of the strings are
* unterminated.
*/
if (len == max)
return (EFAULT);

strp[i] = buf;
buf += strlen(buf) + 1;
buf += len + 1;
}
break;
}
}
return (0);
}

static int
Expand Down Expand Up @@ -3058,7 +3075,7 @@ nvs_native_nvp_op(nvstream_t *nvs, nvpair_t *nvp)
ret = nvpair_native_embedded_array(nvs, nvp);
break;
case DATA_TYPE_STRING_ARRAY:
nvpair_native_string_array(nvs, nvp);
ret = nvpair_native_string_array(nvs, nvp);
break;
default:
break;
Expand Down
Loading