diff options
author | Richard Yao <[email protected]> | 2022-10-14 22:55:48 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-10-18 15:34:44 -0700 |
commit | 3146fc7edf7e1290396b92d51952b9188b873e7f (patch) | |
tree | 1b0055449debb3eeee5b658f13c60a01a793d459 /module/zfs/zap_micro.c | |
parent | 711b35dc24a8165929a9402ff8406248b65467bc (diff) |
Fix NULL pointer passed to strlcpy from zap_lookup_impl()
Clang's static analyzer pointed out that whenever zap_lookup_by_dnode()
is called, we have the following stack where strlcpy() is passed a NULL
pointer for realname from zap_lookup_by_dnode():
strlcpy()
zap_lookup_impl()
zap_lookup_norm_by_dnode()
zap_lookup_by_dnode()
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #14044
Diffstat (limited to 'module/zfs/zap_micro.c')
-rw-r--r-- | module/zfs/zap_micro.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/module/zfs/zap_micro.c b/module/zfs/zap_micro.c index 58a5c9f60..4bf8a322e 100644 --- a/module/zfs/zap_micro.c +++ b/module/zfs/zap_micro.c @@ -990,8 +990,10 @@ zap_lookup_impl(zap_t *zap, const char *name, } else { *(uint64_t *)buf = MZE_PHYS(zap, mze)->mze_value; - (void) strlcpy(realname, - MZE_PHYS(zap, mze)->mze_name, rn_len); + if (realname != NULL) + (void) strlcpy(realname, + MZE_PHYS(zap, mze)->mze_name, + rn_len); if (ncp) { *ncp = mzap_normalization_conflict(zap, zn, mze); |