From 3239296bf3de97b0c9eb0523066a111cae9d9531 Mon Sep 17 00:00:00 2001 From: Ludovic Chopin Date: Sun, 30 May 2021 20:19:02 +0200 Subject: [PATCH] issue #1363: Fix crc32 for 32bit processors --- admin/include/pclzip.lib.php | 4 ++-- include/template.class.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/admin/include/pclzip.lib.php b/admin/include/pclzip.lib.php index 3bb44d6a5..215a9f613 100644 --- a/admin/include/pclzip.lib.php +++ b/admin/include/pclzip.lib.php @@ -2677,7 +2677,7 @@ @fclose($v_file); // ----- Calculate the CRC - $p_header['crc'] = @crc32($v_content); + $p_header['crc'] = @hash("crc32b", $v_content); // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { @@ -2715,7 +2715,7 @@ $v_content = $p_filedescr['content']; // ----- Calculate the CRC - $p_header['crc'] = @crc32($v_content); + $p_header['crc'] = @hash("crc32b", $v_content); // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { diff --git a/include/template.class.php b/include/template.class.php index b88d1a7dd..ae3e8eeec 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -212,7 +212,7 @@ class Template { $compile_id = "1"; $compile_id .= ($real_dir = realpath($dir))===false ? $dir : $real_dir; - $this->smarty->compile_id = base_convert(crc32($compile_id), 10, 36 ); + $this->smarty->compile_id = base_convert(hash("crc32b", $compile_id), 16, 36 ); } } @@ -1021,7 +1021,7 @@ var s,after = document.getElementsByTagName(\'script\')[document.getElementsByTa $this->smarty->registerFilter($type, $callback); } } - $this->smarty->compile_id .= '.'.base_convert(crc32($compile_id), 10, 36); + $this->smarty->compile_id .= '.'.base_convert(hash("crc32b", $compile_id), 16, 36); } } @@ -1896,7 +1896,7 @@ final class FileCombiner if (count($pending)>1) { $key = join('>', $key); - $file = PWG_COMBINED_DIR . base_convert(crc32($key),10,36) . '.' . $this->type; + $file = PWG_COMBINED_DIR . base_convert(hash("crc32b", $key), 16, 36) . '.' . $this->type; if ($force || !file_exists(PHPWG_ROOT_PATH.$file) ) { $output = ''; @@ -1945,7 +1945,7 @@ final class FileCombiner $key = array($combinable->path, $combinable->version); if ($conf['template_compile_check']) $key[] = filemtime( PHPWG_ROOT_PATH . $combinable->path ); - $file = PWG_COMBINED_DIR . 't' . base_convert(crc32(implode(',',$key)),10,36) . '.' . $this->type; + $file = PWG_COMBINED_DIR . 't' . base_convert(hash("crc32b", implode(',', $key)), 16, 36) . '.' . $this->type; if (!$force && file_exists(PHPWG_ROOT_PATH.$file) ) { $combinable->path = $file;