12 Star 0 Fork 12

src-openEuler/flex

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
scanner-prevent-overflow-in-add_action.patch 927 Bytes
一键复制 编辑 原始数据 按行查看 历史
yixiangzhike 提交于 5年前 . update to 2.6.4
From 23882383d45dcd37b5177835c873f4e1d9582db1 Mon Sep 17 00:00:00 2001
From: Explorer09 <explorer09@gmail.com>
Date: Fri, 13 Oct 2017 16:59:26 +0800
Subject: [PATCH] scanner: prevent overflow in add_action()
---
src/misc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/misc.c b/src/misc.c
index fa33a5b..745e6a8 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -116,15 +116,14 @@ void add_action (const char *new_text)
int len = (int) strlen (new_text);
while (len + action_index >= action_size - 10 /* slop */ ) {
- int new_size = action_size * 2;
- if (new_size <= 0)
+ if (action_size > INT_MAX / 2)
/* Increase just a little, to try to avoid overflow
* on 16-bit machines.
*/
action_size += action_size / 8;
else
- action_size = new_size;
+ action_size = action_size * 2;
action_array =
reallocate_character_array (action_array,
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/flex.git
git@gitee.com:src-openeuler/flex.git
src-openeuler
flex
flex
master

搜索帮助