diff options
author | Richard Yao <[email protected]> | 2022-09-30 20:02:57 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-30 17:02:57 -0700 |
commit | 67395be0c2bd337f3b480d295a485117ac6bc61b (patch) | |
tree | 3ea2d41cf57e552c3a73f869d04ace0f5bcfba4b /cmd/zstream | |
parent | a36b37d4de5d90bf3016a7ca23686c3295f6b01a (diff) |
Fix userland dereference NULL return value bugs
* `zstream_do_token()` does not handle failures from `libzfs_init()`
* `ztest_global_vars_to_zdb_args()` does not handle failures from
`calloc()`.
* `zfs_snapshot_nvl()` will pass an offset to a NULL pointer as a
source to `strlcpy()` if the provided nvlist is `NULL`.
We handle these by doing what the existing error handling does for other
errors involving these functions.
Coverity complained about these. It had complained about several more,
but one was fixed by 570ca4441e0583c8dcb5c7179f5eb331d1172784 and
another was a false positive. The remaining complaints labelled
"dereferece null return vaue" involve fetching things stored in
in-kernel data structures via `list_head()/list_next()`,
`AVL_PREV()/AVL_NEXT()` and `zfs_btree_find()`. Most of them occur in
void functions that have no error handling. They are much harder to
analyze than the two fixed in this patch, so they are left for a
follow-up patch.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #13971
Diffstat (limited to 'cmd/zstream')
-rw-r--r-- | cmd/zstream/zstream_token.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/zstream/zstream_token.c b/cmd/zstream/zstream_token.c index 23cc56dce..795a37263 100644 --- a/cmd/zstream/zstream_token.c +++ b/cmd/zstream/zstream_token.c @@ -49,6 +49,7 @@ int zstream_do_token(int argc, char *argv[]) { char *resume_token = NULL; + libzfs_handle_t *hdl; if (argc < 2) { (void) fprintf(stderr, "Need to pass the resume token\n"); @@ -57,7 +58,10 @@ zstream_do_token(int argc, char *argv[]) resume_token = argv[1]; - libzfs_handle_t *hdl = libzfs_init(); + if ((hdl = libzfs_init()) == NULL) { + (void) fprintf(stderr, "%s\n", libzfs_error_init(errno)); + return (1); + } nvlist_t *resume_nvl = zfs_send_resume_token_to_nvlist(hdl, resume_token); |