Skip to content

Commit

Permalink
Fix NULL pointer passed to strlcpy from zap_lookup_impl()
Browse files Browse the repository at this point in the history
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 openzfs#14044
  • Loading branch information
ryao authored and tonyhutter committed Dec 1, 2022
1 parent a5f17a9 commit bbec0e6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions module/zfs/zap_micro.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,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);
Expand Down

0 comments on commit bbec0e6

Please sign in to comment.