Project

General

Profile

Bug #11466 » patch-dynamic-pcre-recursion-limit.diff

Lower PCRE recursion limit based on stack size (doesn't prevent the crash -- but may aid in debugging) - Jim Pingle, 06/03/2021 09:15 AM

View differences:

src/etc/rc.php_ini_setup
77 77
	fi
78 78
fi
79 79

  
80
PCRE_RECURSION_LIMIT=100000
81
STACKSIZE=$(/usr/bin/ulimit -s)
82
if [ ${STACKSIZE} -gt 32000 -a ${STACKSIZE} -le 64000 ]; then
83
	PCRE_RECURSION_LIMIT=64000
84
elif [ ${STACKSIZE} -gt 16000 -a ${STACKSIZE} -le 32000 ]; then
85
	PCRE_RECURSION_LIMIT=32000
86
elif [ ${STACKSIZE} -gt 8000 -a ${STACKSIZE} -le 16000 ]; then
87
	PCRE_RECURSION_LIMIT=16000
88
elif [ ${STACKSIZE} -gt 4000 -a ${STACKSIZE} -le 8000 ]; then
89
	PCRE_RECURSION_LIMIT=8000
90
elif [ ${STACKSIZE} -le 4000 ]; then
91
	PCRE_RECURSION_LIMIT=500
92
fi
93

  
80 94
# Set upload directory
81 95
UPLOADTMPDIR="/tmp"
82 96

  
......
206 220
session.hash_function = 1
207 221
${error_reporting}
208 222

  
223
[Pcre]
224
pcre.recursion_limit = ${PCRE_RECURSION_LIMIT}
225

  
209 226
; Extensions
210 227

  
211 228
EOF
(2-2/3)