From bbc8b339c0eb6d3a7197500bf096bdf718e7388e Mon Sep 17 00:00:00 2001 From: Zoltan Fridrich Date: Fri, 10 May 2024 16:50:10 +0200 Subject: [PATCH] docproc: guard against overflow Signed-off-by: Zoltan Fridrich Signed-off-by: Stephan Mueller --- lib/doc/bin/docproc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/doc/bin/docproc.c b/lib/doc/bin/docproc.c index 74b3cdb..899bdf4 100644 --- a/lib/doc/bin/docproc.c +++ b/lib/doc/bin/docproc.c @@ -35,6 +35,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -402,7 +403,8 @@ static void find_all_symbols(char *filename) do { while ((ret = read(pipefd[0], data + data_len, - 4096)) > 0) { + 4096)) > 0 && + data_len <= SIZE_MAX - 4096 - (size_t)ret) { data_len += (size_t)ret; data = realloc(data, data_len + 4096); if (!data) {