1 Star 0 Fork 103

fly_fzc/systemd

forked from src-openEuler/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fix-cgtop-sscanf-return-code-checks.patch 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
hanjinpeng 提交于 2024-07-26 14:08 +08:00 . cgtop: fix sscanf return code checks
From bab356f5a0b8d4a43a71076c2333ff4da7ed737e Mon Sep 17 00:00:00 2001
From: Luca Boccassi <bluca@debian.org>
Date: Fri, 19 Jan 2024 15:12:49 +0000
Subject: [PATCH] cgtop: fix sscanf return code checks
sscanf can return EOF on error, so check that we get a result instead.
CodeQL#2386 and CodeQL#2387
(cherry picked from commit 204d52c4b79eb19d2919cb5214e999c58a6679c6)
---
src/cgtop/cgtop.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index e34da7cf728..ca514554408 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -310,9 +310,9 @@ static int process(
if (all_unified) {
while (!isempty(l)) {
- if (sscanf(l, "rbytes=%" SCNu64, &k))
+ if (sscanf(l, "rbytes=%" SCNu64, &k) == 1)
rd += k;
- else if (sscanf(l, "wbytes=%" SCNu64, &k))
+ else if (sscanf(l, "wbytes=%" SCNu64, &k) == 1)
wr += k;
l += strcspn(l, WHITESPACE);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fly_fzc/systemd.git
git@gitee.com:fly_fzc/systemd.git
fly_fzc
systemd
systemd
master

搜索帮助