Skip to content

Commit

Permalink
Fix potential NULL pointer dereference in lzc_ioctl()
Browse files Browse the repository at this point in the history
Users are allowed to pass NULL to resultp, but we unconditionally assume
that they never do. When an external user does pass NULL to resultp, we
dereference a NULL pointer.

Clang's static analyzer complained about this.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes openzfs#14008
  • Loading branch information
ryao authored and tonyhutter committed Dec 1, 2022
1 parent d05f247 commit d016ca1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libzfs_core/libzfs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name,
break;
}
}
if (zc.zc_nvlist_dst_filled) {
if (zc.zc_nvlist_dst_filled && resultp != NULL) {
*resultp = fnvlist_unpack((void *)(uintptr_t)zc.zc_nvlist_dst,
zc.zc_nvlist_dst_size);
}
Expand Down

0 comments on commit d016ca1

Please sign in to comment.