pcre2/backport-fix-a-possible-integer-overflow-in-DFA-matching-305.patch

24 lines
790 B
Diff

From d231944236c6516de2831cbdde3069dab180ae81 Mon Sep 17 00:00:00 2001
From: pkuzco <b.naamneh@gmail.com>
Date: Mon, 9 Oct 2023 17:46:42 +0200
Subject: [PATCH] fix a possible integer overflow in DFA matching (#305)
---
src/pcre2_dfa_match.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pcre2_dfa_match.c b/src/pcre2_dfa_match.c
index 518ac07..13b1ae4 100644
--- a/src/pcre2_dfa_match.c
+++ b/src/pcre2_dfa_match.c
@@ -428,7 +428,7 @@ overflow. */
else
{
- uint32_t newsize = (rws->size >= UINT32_MAX/2)? UINT32_MAX/2 : rws->size * 2;
+ uint32_t newsize = (rws->size >= UINT32_MAX/(sizeof(int)*2))? UINT32_MAX/sizeof(int) : rws->size * 2;
uint32_t newsizeK = newsize/(1024/sizeof(int));
if (newsizeK + mb->heap_used > mb->heap_limit)
--
2.33.0