Skip to content

Commit

Permalink
Don't erase final byte of envblock
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pcd1193182 authored Jun 8, 2020
1 parent c9e319f commit b2f3709
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libzfs/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b2f3709

Please sign in to comment.