15 Star 2 Fork 66

src-openEuler/util-linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-sys-utils-fix-add-NULL-check-for-mnt_fs_get_target-r.patch 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
zhangyao2022 提交于 2025-03-03 20:09 +08:00 . backport community patches
From 0fabec8c7fda554b79327d8713352e7a07539895 Mon Sep 17 00:00:00 2001
From: AntonMoryakov <ant.v.moryakov@gmail.com>
Date: Tue, 14 Jan 2025 18:06:49 +0300
Subject: [PATCH] sys-utils: fix add NULL check for mnt_fs_get_target return
value
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>
Reference:https://github.com/util-linux/util-linux/commit/0fabec8c7fda554b79327d8713352e7a07539895
Conflict:NA
---
sys-utils/lsns.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c
index 500bc013..93bbd758 100644
--- a/sys-utils/lsns.c
+++ b/sys-utils/lsns.c
@@ -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);
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/util-linux.git
git@gitee.com:src-openeuler/util-linux.git
src-openeuler
util-linux
util-linux
master

搜索帮助