8 Star 1 Fork 7

src-anolis-os/rasdaemon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1057-checkpatch.pl-warn-also-about-strcat-and-sprintf-usa.patch 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
From c85de5ac34af143ffb30bcaffcf6f54029d60dbf Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <[email protected]>
Date: Thu, 18 Jul 2024 13:01:00 +0200
Subject: [PATCH 57/85] checkpatch.pl: warn also about strcat and sprintf
usages
strcpy, strncpy and sprintf aren't safe, as they don't check
buffer overflows. Change the checkpatch logic to warn about
such usages.
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
---
scripts/checkpatch.pl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e81e509..7ed2ec6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6675,10 +6675,10 @@ sub process {
# }
# }
-# strcpy should be avoided
- if ($line =~ /\bstrcpy\s*\(/) {
+# strcpy and strcat should be avoided
+ if ($line =~ /\b(strcpy|strcat|sprintf)\s*\(/) {
WARN("STRCPY",
- "Please avoid strcpy\n" . $herecurr);
+ "Please avoid $1 as it doesn't check buffer size\n" . $herecurr);
}
# ethtool_sprintf uses that should likely be ethtool_puts
--
2.33.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-anolis-os/rasdaemon.git
[email protected]:src-anolis-os/rasdaemon.git
src-anolis-os
rasdaemon
rasdaemon
a8

搜索帮助