]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sys-utils: fix add NULL check for mnt_fs_get_target return value
authorAntonMoryakov <ant.v.moryakov@gmail.com>
Tue, 14 Jan 2025 15:06:49 +0000 (18:06 +0300)
committerAntonMoryakov <ant.v.moryakov@gmail.com>
Tue, 14 Jan 2025 15:07:21 +0000 (18:07 +0300)
The static analyzer flagged a potential issue: the return value of
mnt_fs_get_target(fs) could be NULL, but it was dereferenced without
a check. This could lead to undefined behavior.

Added a NULL check before using the tgt pointer. If tgt is NULL,
the current iteration is skipped.

ChanChanges:
- Added if (!tgt) check before using tgt.

Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
sys-utils/lsns.c

index 500bc013c44fb36effadf7022364e4a36fc968d2..93bbd758b24a7948ba80c82d84b161434d66b444 100644 (file)
@@ -1132,6 +1132,9 @@ static int nsfs_xasputs(char **str,
 
                const char *tgt = mnt_fs_get_target(fs);
 
+               if(!tgt)
+                       continue;
+
                if (!*str)
                        xasprintf(str, "%s", tgt);