1 Star 0 Fork 33

ExtinctFire/shadow

forked from src-openEuler/shadow 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-libmisc-add-check-fopen-return-value-in-read_random_.patch 887 Bytes
一键复制 编辑 原始数据 按行查看 历史
From a43d0b95c44b2c36025452b772b9d4b251281e3e Mon Sep 17 00:00:00 2001
From: juyin <zhuyan34@huawei.com>
Date: Wed, 30 Mar 2022 19:21:32 +0800
Subject: [PATCH] libmisc: add check fopen return value in read_random_bytes()
Returns null when fopen fails. Then, using fread with a null pointer will cause a segfault.
Signed-off-by: Yan Zhu <zhuyan34@huawei.com>
Reference: https://github.com/shadow-maint/shadow/commit/a43d0b95c44b2c36025452b772b9d4b251281e3e
Conflict: NA
---
libmisc/salt.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libmisc/salt.c b/libmisc/salt.c
index f8ac5669..ebf162fc 100644
--- a/libmisc/salt.c
+++ b/libmisc/salt.c
@@ -175,6 +175,9 @@ static long read_random_bytes (void)
#else
FILE *f = fopen ("/dev/urandom", "r");
+ if (NULL == f) {
+ goto fail;
+ }
if (fread (&randval, sizeof (randval), 1, f) != 1) {
fclose(f);
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/extinctfire/shadow.git
git@gitee.com:extinctfire/shadow.git
extinctfire
shadow
shadow
master

搜索帮助