1 Star 0 Fork 101

YukariChiba/systemd

forked from src-openEuler/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-macro-account-for-negative-values-in-DECIMAL_STR_WID.patch 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
From 19c0ce4c68fd424f48a71afbc9d8b7b67ba58709 Mon Sep 17 00:00:00 2001
From: Frantisek Sumsal <frantisek@sumsal.cz>
Date: Sun, 13 Mar 2022 14:45:03 +0100
Subject: [PATCH] macro: account for negative values in DECIMAL_STR_WIDTH()
With negative numbers we wouldn't account for the minus sign, thus
returning a string with one character too short, triggering buffer
overflows in certain situations.
(cherry picked from commit e3dd9ea8ea4510221f73071ad30ee657ca77565d)
(cherry picked from commit 25b3c48ec5203a1220daaf33b8df6e50e79fd74a)
Conflict:NA
Reference:https://github.com/systemd/systemd-stable/commit/19c0ce4c68fd424f48a71afbc9d8b7b67ba58709
---
src/basic/macro.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/basic/macro.h b/src/basic/macro.h
index 072fed4378..5a3027ae5c 100644
--- a/src/basic/macro.h
+++ b/src/basic/macro.h
@@ -349,7 +349,7 @@ static inline int __coverity_check_and_return__(int condition) {
#define DECIMAL_STR_WIDTH(x) \
({ \
typeof(x) _x_ = (x); \
- unsigned ans = 1; \
+ unsigned ans = 2; \
while ((_x_ /= 10) != 0) \
ans++; \
ans; \
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/YukariChiba/systemd.git
git@gitee.com:YukariChiba/systemd.git
YukariChiba
systemd
systemd
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385