1 Star 0 Fork 10

jinlun/dim

forked from src-openEuler/dim 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Fix-the-issue-that-the-memory-allocation-is-too-larg.patch 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
From ebcef654f8825e1db58a2d9bc62727ab9d4728a0 Mon Sep 17 00:00:00 2001
From: jinlun <jinlun@huawei.com>
Date: Mon, 17 Jun 2024 20:33:05 +0800
Subject: [PATCH 08/14] Fix the issue that the memory allocation is too large.
---
src/common/dim_utils.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/common/dim_utils.c b/src/common/dim_utils.c
index 598e824..57ea3e9 100644
--- a/src/common/dim_utils.c
+++ b/src/common/dim_utils.c
@@ -9,6 +9,8 @@
#include "dim_safe_func.h"
#include "dim_utils.h"
+#define DIM_MAX_LINE_BUF (8 * 1024)
+
int dim_get_absolute_path(const char *path, const char **result)
{
int ret = 0;
@@ -83,6 +85,11 @@ int dim_parse_line_buf(char *buf, loff_t len, int (*line_parser)(char *, int, vo
line = &buf[i + 1];
} else {
line_len = buf + i - line + 1;
+ if (line_len + 1 > DIM_MAX_LINE_BUF) {
+ dim_err("failed to alloc memory for line buff\n");
+ return -ENOMEM;
+ }
+
line_buf = dim_kzalloc_gfp(line_len + 1);
if (line_buf == NULL)
return -ENOMEM;
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jinlun123123/dim.git
git@gitee.com:jinlun123123/dim.git
jinlun123123
dim
dim
master

搜索帮助