From f25a807da3be09beff4d6fdca1e700242b33779c Mon Sep 17 00:00:00 2001 From: Sujith H Date: Mon, 12 Feb 2018 20:52:34 +0530 Subject: [PATCH] [stable10] Check exec and stat method before using it Before using exec and stat method in 32 bit machines, a check is required if they are available or not. Else fallback to the filemtime(path); Signed-off-by: Sujith H --- lib/private/Files/Storage/Local.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 5c278de6b410..44a67d7238a2 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -180,12 +180,26 @@ public function filemtime($path) { return false; } if (PHP_INT_SIZE === 4) { - if (\OC_Util::runningOn('linux')) { - return (int) exec ('stat -c %Y '. escapeshellarg ($fullPath)); - } else if (\OC_Util::runningOn('bsd') || \OC_Util::runningOn('mac')) { - return (int) exec ('stat -f %m '. escapeshellarg ($fullPath)); + /** + * Check if exec is available to use before calling it. + */ + if (function_exists('exec') === true) { + $result = 0; + $returnVar = 0; + if (\OC_Util::runningOn('linux')) { + $result = (int)exec('stat -c %Y ' . escapeshellarg($fullPath), $output, $returnVar); + } else if (\OC_Util::runningOn('bsd') || \OC_Util::runningOn('mac')) { + $result = (int)exec('stat -f %m ' . escapeshellarg($fullPath), $output, $returnVar); + } + + /** + * If the result is zero, then stat is missing. + * Additionally check the return status from the shell. + */ + if ($returnVar === 0) { + return $result; + } } - return false; } return filemtime($fullPath); }