From 5536dcb1f7a553438dc249d9c7658f483c75c685 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 26 Nov 2005 20:17:43 +0000 Subject: [PATCH] * Fix ulimit parameters for wfShellExec when memory_limit is specified in 'm' With memory_limit of '50M', it got automatically turned into '50' in a numeric context, which ended up passing *zero* kilobytes for ulimit. This would make nothing able to run on Linux, things would just segfault. --- RELEASE-NOTES | 2 ++ includes/GlobalFunctions.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 76fc7fc321..9aa1e9b535 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -254,6 +254,8 @@ fully support the editing toolbar, but was found to be too confusing. * Changed mail form to have a bigger message entry box (like for editing a page * Support in templates loaded through preload= parameter +* Fix ulimit parameters for wfShellExec when memory_limit is specified in 'm' + === Caveats === diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index d97740eba9..72d0d80c54 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1588,6 +1588,9 @@ function wfShellExec( $cmd ) if ( php_uname( 's' ) == 'Linux' ) { $time = ini_get( 'max_execution_time' ); $mem = ini_get( 'memory_limit' ); + if( preg_match( '/^([0-9]+)[Mm]$/', trim( $mem ), $m ) ) { + $mem = intval( $m[1] * (1024*1024) ); + } if ( $time > 0 && $mem > 0 ) { $script = "$IP/bin/ulimit.sh"; if ( is_executable( $script ) ) { -- 2.20.1