From ebcef654f8825e1db58a2d9bc62727ab9d4728a0 Mon Sep 17 00:00:00 2001 From: jinlun 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