From 8b19fca9927cdec07cc9dd09bdcf2496a5ae69b3 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Wed, 25 Jan 2017 08:30:19 -0600 Subject: [PATCH] sanitize the image path before processing --- web/views/file.php | 56 --------------------------------------------- web/views/image.php | 31 ++++++++++++------------- 2 files changed, 15 insertions(+), 72 deletions(-) delete mode 100644 web/views/file.php diff --git a/web/views/file.php b/web/views/file.php deleted file mode 100644 index 9b49ff059..000000000 --- a/web/views/file.php +++ /dev/null @@ -1,56 +0,0 @@ - diff --git a/web/views/image.php b/web/views/image.php index a7aacb6d2..df454d792 100644 --- a/web/views/image.php +++ b/web/views/image.php @@ -78,24 +78,23 @@ if ( empty($_REQUEST['path']) ) } else { $errorText = "No image path"; } -} -else -{ - $path = ZM_DIR_EVENTS . '/' . $_REQUEST['path']; - if ( !empty($user['MonitorIds']) ) - { - $imageOk = false; - $pathMonId = substr( $path, 0, strspn( $path, "1234567890" ) ); - foreach ( preg_split( '/["\'\s]*,["\'\s]*/', $user['MonitorIds'] ) as $monId ) - { - if ( $pathMonId == $monId ) - { - $imageOk = true; - break; +} else { + $path = realpath(ZM_DIR_EVENTS . '/' . $_REQUEST['path']); + if(strpos($path, ZM_DIR_EVENTS) == 0 && strpos($path, ZM_DIR_EVENTS) === true) { + if ( !empty($user['MonitorIds']) ) { + $imageOk = false; + $pathMonId = substr( $path, 0, strspn( $path, "1234567890" ) ); + foreach ( preg_split( '/["\'\s]*,["\'\s]*/', $user['MonitorIds'] ) as $monId ) { + if ( $pathMonId == $monId ) { + $imageOk = true; + break; + } } + if ( !$imageOk ) + $errorText = "No image permissions"; } - if ( !$imageOk ) - $errorText = "No image permissions"; + } else { + $errorText = "Invalid image path"; } }