3 Star 0 Fork 6

ocs-commit/audit

forked from OpenCloudOS Stream/audit 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
a7f73aec4ca1931a494cd2893357737d59ea0e29.patch 945 Bytes
一键复制 编辑 原始数据 按行查看 历史
ocs-bot 提交于 2025-01-02 19:57 +08:00 . - [Type] bugfix
From a7f73aec4ca1931a494cd2893357737d59ea0e29 Mon Sep 17 00:00:00 2001
From: cgzones <cgzones@googlemail.com>
Date: Mon, 15 Jan 2024 21:44:04 +0100
Subject: [PATCH] lib: avoid UB on sequence wrap-around (#347)
Signed integer overflow is undefined, allowing compilers to optimize the
condition `++sequence < 0` away.
---
lib/netlink.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/netlink.c b/lib/netlink.c
index 66a1e7c89..ff26d33f8 100644
--- a/lib/netlink.c
+++ b/lib/netlink.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
#include <time.h>
#include <sys/poll.h>
#include "libaudit.h"
@@ -220,8 +221,10 @@ int __audit_send(int fd, int type, const void *data, unsigned int size, int *seq
return -errno;
}
- if (++sequence < 0)
+ if (sequence == INT_MAX)
sequence = 1;
+ else
+ sequence++;
*seq = sequence;
memset(&req, 0, sizeof(req));
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ocs-commit/audit.git
git@gitee.com:ocs-commit/audit.git
ocs-commit
audit
audit
master

搜索帮助