]> 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)
committerGitHub <noreply@github.com>
Fri, 14 Oct 2022 20:33:22 +0000 (13:33 -0700)
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 16bd9af1bbc8de5ec6809a0cc9c881c8959df789..3fe65e665b9c18d5be638729b0a2aa83d36b179d 100644 (file)
@@ -235,7 +235,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);
        }