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 <behlendorf1@llnl.gov> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #14044
This commit is contained in:
parent
a5f17a94d3
commit
bbec0e60a8
|
@ -988,8 +988,10 @@ zap_lookup_impl(zap_t *zap, const char *name,
|
||||||
} else {
|
} else {
|
||||||
*(uint64_t *)buf =
|
*(uint64_t *)buf =
|
||||||
MZE_PHYS(zap, mze)->mze_value;
|
MZE_PHYS(zap, mze)->mze_value;
|
||||||
|
if (realname != NULL)
|
||||||
(void) strlcpy(realname,
|
(void) strlcpy(realname,
|
||||||
MZE_PHYS(zap, mze)->mze_name, rn_len);
|
MZE_PHYS(zap, mze)->mze_name,
|
||||||
|
rn_len);
|
||||||
if (ncp) {
|
if (ncp) {
|
||||||
*ncp = mzap_normalization_conflict(zap,
|
*ncp = mzap_normalization_conflict(zap,
|
||||||
zn, mze);
|
zn, mze);
|
||||||
|
|
Loading…
Reference in New Issue