java-topology/defects/dolibarr/patch/dolibarr-0001-filecheck-insignature-in_array.patch

14 lines
866 B
Diff

# UNDF: UNDF-2026-000000866
--- a/htdocs/blockedlog/admin/filecheck.php
+++ b/htdocs/blockedlog/admin/filecheck.php
@@ -409,9 +409,10 @@
// Complete with list of new files into $file_list['added']
if (empty($onlymodifiedorremoved)) {
+ $insignature_set = array_flip($file_list['insignature']); // O(1) lookup instead of O(N) in_array
foreach ($scanfiles as $valfile) {
$tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']);
- if (!in_array($tmprelativefilename, $file_list['insignature'])) {
+ if (!isset($insignature_set[$tmprelativefilename])) {
$hashnewfile = @hash_file($algo, $valfile['fullname']); // Can fails if we don't have permission to open/read file
$file_list['added'][] = array('filename' => $tmprelativefilename, 'hash' => $hashnewfile, 'algo' => $algo);
}