Don't erase final byte of envblock

When we copy the envblock's contents out, we currently treat it as 
a normal C string. However, this functionality is supposed to more
closely emulate interacting with a file. As a consequence, we were 
incorrectly truncating the contents of the envblock by replacing 
the final byte of the buffer with a null character.

Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #10405
This commit is contained in:
Paul Dagnelie 2020-06-08 08:58:13 -07:00 committed by GitHub
parent c9e319faae
commit b2f3709c3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -4539,7 +4539,7 @@ zpool_get_bootenv(zpool_handle_t *zhp, char *outbuf, size_t size, off_t offset)
return (0);
}
strlcpy(outbuf, envmap + offset, size);
strncpy(outbuf, envmap + offset, size);
int bytes = MIN(strlen(envmap + offset), size);
fnvlist_free(nvl);
return (bytes);