Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync pclzip with chamilo/pclzip ? #23

Open
williamdes opened this issue Jul 28, 2024 · 1 comment
Open

Sync pclzip with chamilo/pclzip ? #23

williamdes opened this issue Jul 28, 2024 · 1 comment

Comments

@williamdes
Copy link
Contributor

Should we copy the upstream changes from https://github.com/chamilo/pclzip ?

The diff to apply is minimal
It seems that it contains a security fix and a PHP 7.1 compat bug fix around the ini_ functions

diff --git a/libs/PclZip/pclzip.lib.php b/libs/PclZip/pclzip.lib.php
index 1189e9f..dbe5c28 100644
--- a/libs/PclZip/pclzip.lib.php
+++ b/libs/PclZip/pclzip.lib.php
@@ -1,6 +1,6 @@
 <?php
 // --------------------------------------------------------------------------------
-// PhpConcept Library - Zip Module 2.8.2
+// PhpConcept Library - Zip Module 2.8.4
 // --------------------------------------------------------------------------------
 // License GNU/LGPL - Vincent Blavet - August 2009
 // http://www.phpconcept.net
@@ -1717,7 +1717,7 @@ class PclZip
 					$v_function_name = $p_options_list[$i + 1];
 
 					// ----- Check that the value is a valid existing function
-					if ((is_string($v_function_name) && !function_exists($v_function_name)) && !is_callable($v_function_name)) {
+					if (!function_exists($v_function_name)) {
 						// ----- Error log
 						PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '" . $v_function_name . "()' is not an existing function for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
 
@@ -1784,9 +1784,10 @@ class PclZip
 		}
 
 		// ----- Get 'memory_limit' configuration value
-		$v_memory_limit = trim(ini_get('memory_limit'));
+		$v_memory_limit = ini_get('memory_limit');
+		$v_memory_limit = trim($v_memory_limit);
 		$last           = strtolower(substr($v_memory_limit, -1));
-		$v_memory_limit = intval($v_memory_limit);
+		$v_memory_limit = preg_replace('/\s*[KkMmGg]$/', '', $v_memory_limit);
 
 		if ($last == 'g') {
 			//$v_memory_limit = $v_memory_limit*1024*1024*1024;
@@ -3512,6 +3513,12 @@ class PclZip
 			}
 		}
 
+		// Patch for Zip Traversal vulnerability
+		if (strpos($p_entry['stored_filename'], '../') !== false || strpos($p_entry['stored_filename'], '..\\') !== false) {
+			$p_entry['stored_filename'] = basename($p_entry['stored_filename']);
+			$p_entry['filename'] = basename($p_entry['stored_filename']);
+		}
@sgiehl
Copy link
Member

sgiehl commented Jul 29, 2024

Sounds good to me to apply such fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants