]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix potential NULL pointer dereference in lzc_ioctl()
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Fri, 14 Oct 2022 20:33:22 +0000 (16:33 -0400)
committerTony Hutter <hutter2@llnl.gov>
Thu, 1 Dec 2022 20:39:41 +0000 (12:39 -0800)
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 #14008

lib/libzfs_core/libzfs_core.c

index 1e6bbcd561faabe949535bd51c13cc47f035eb4a..855d8cb0afb999ed32a40ad2a40b0f1b9fbe49b0 100644 (file)
@@ -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);
        }