From bef5ab005e6c2ec2f604739b7bc75edea8d02315 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 14 Jun 2021 16:29:21 +0200 Subject: [PATCH] include/strutils: fix heap-buffer-overflow in normalize_whitespace() Signed-off-by: Karel Zak --- include/strutils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/strutils.h b/include/strutils.h index 7969a84d0c..2e5a2aad4c 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -334,7 +334,7 @@ static inline size_t normalize_whitespace(unsigned char *str) else str[x++] = str[i++]; } - if (nsp) /* tailing space */ + if (nsp && x > 0) /* tailing space */ x--; str[x] = '\0'; return x; -- 2.47.3