zfs_get_temporary_prop() should not pass NULL to strcpy()

`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
This commit is contained in:
Richard Yao 2022-12-23 00:00:38 -05:00 committed by Brian Behlendorf
parent 14872aaa4f
commit 3a7d2a0ce0
2 changed files with 4 additions and 2 deletions

View 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);

View 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);