]> git.proxmox.com Git - mirror_zfs.git/commitdiff
zfs_get_temporary_prop() should not pass NULL to strcpy()
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Fri, 23 Dec 2022 05:00:38 +0000 (00:00 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 6 Feb 2023 19:08:57 +0000 (11:08 -0800)
`dsl_dir_activity_in_progress()` can call `zfs_get_temporary_prop()` with
the forth value set to NULL, which will pass NULL to `strcpy()` when
there is a match

Clang's static analyzer caught this with the help of CodeChecker for
Cross Translation Unit analysis.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14456

module/os/freebsd/zfs/zfs_vfsops.c
module/os/linux/zfs/zfs_vfsops.c

index 2820f10b5de8c682d8d3b30fa3b3449548aa20a4..a1e0595bda34a218d1847048f689ad0529906dea 100644 (file)
@@ -230,7 +230,8 @@ zfs_get_temporary_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop, uint64_t *val,
 
        vfs_unbusy(vfsp);
        if (tmp != *val) {
-               (void) strcpy(setpoint, "temporary");
+               if (setpoint)
+                       (void) strcpy(setpoint, "temporary");
                *val = tmp;
        }
        return (0);
index c921e587c75cafe52a66413ba45fc698925cb0f4..2d9b27a90884116adc9aff95892d3f519d1ae4c5 100644 (file)
@@ -608,7 +608,8 @@ zfs_get_temporary_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop, uint64_t *val,
        }
 
        if (tmp != *val) {
-               (void) strcpy(setpoint, "temporary");
+               if (setpoint)
+                       (void) strcpy(setpoint, "temporary");
                *val = tmp;
        }
        return (0);