From 551031da09f461a8cef3f6e5883bd0baf1a872dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 13 Jul 2016 09:37:24 +0200 Subject: [PATCH] Validate image scaling dimensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure we pass only integers and they are not too big. Signed-off-by: Michal Čihař --- transformation_wrapper.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/transformation_wrapper.php b/transformation_wrapper.php index f55d8f9935..8240a06845 100644 --- a/transformation_wrapper.php +++ b/transformation_wrapper.php @@ -34,9 +34,20 @@ $request_params = array( 'transform_key', 'where_clause' ); +$size_params = array( + 'newHeight', + 'newWidth', +); foreach ($request_params as $one_request_param) { if (isset($_REQUEST[$one_request_param])) { - $GLOBALS[$one_request_param] = $_REQUEST[$one_request_param]; + if (in_array($one_request_param, $size_params)) { + $GLOBALS[$one_request_param] = intval($_REQUEST[$one_request_param]); + if ($GLOBALS[$one_request_param] > 2000) { + $GLOBALS[$one_request_param] = 2000; + } + } else { + $GLOBALS[$one_request_param] = $_REQUEST[$one_request_param]; + } } }