]> granicus.if.org Git - mutt/commitdiff
Decrease regex failure stack limit. (closes #3955)
authorKevin McCarthy <kevin@8t8.us>
Fri, 14 Jul 2017 22:19:57 +0000 (15:19 -0700)
committerKevin McCarthy <kevin@8t8.us>
Fri, 14 Jul 2017 22:19:57 +0000 (15:19 -0700)
When using alloca(), the built-in regexp library limited the failure
stack to 20,000 entries.  This value is too large, and causes alloca()
to segfault in the example provided in the ticket.

Decrease the limit to 8000.

Thanks to Thorsten Wißmann for the excellent bug report, which made
debugging this much easier.

regex.c

diff --git a/regex.c b/regex.c
index 40979af7412756e6dbf86d0613aae0e12d3071df..fbec647ebb7d26b8626b5c79578e84e7fef93426 100644 (file)
--- a/regex.c
+++ b/regex.c
@@ -1116,7 +1116,7 @@ typedef struct
 #if defined (MATCH_MAY_ALLOCATE)
 /* 4400 was enough to cause a crash on Alpha OSF/1,
    whose default stack limit is 2mb.  */
-int re_max_failures = 20000;
+int re_max_failures = 8000;
 #else
 int re_max_failures = 2000;
 #endif