File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
lib/private/Files/Storage Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -400,8 +400,20 @@ public function fopen($path, $mode) {
400400 return $ result ;
401401 }
402402
403- public function hash ($ type , $ path , $ raw = false ) {
404- return hash_file ($ type , $ this ->getSourcePath ($ path ), $ raw );
403+ public function hash ($ type , $ path , $ raw = false ): string |bool {
404+ $ sourcePath = $ this ->getSourcePath ($ path );
405+ if ($ sourcePath === null || !file_exists ($ sourcePath ) || !is_readable ($ sourcePath )) {
406+ \OC ::$ server ->get (LoggerInterface::class)->error ('Source path does not exist or is not readable: ' . $ sourcePath , ['app ' => 'core ' ]);
407+ return false ;
408+ }
409+
410+ $ validAlgorithms = hash_algos ();
411+ if (!in_array ($ type , $ validAlgorithms )) {
412+ \OC ::$ server ->get (LoggerInterface::class)->error ('Invalid hash algorithm: ' . $ type , ['app ' => 'core ' ]);
413+ return false ;
414+ }
415+
416+ return hash_file ($ type , $ sourcePath , $ raw );
405417 }
406418
407419 public function free_space ($ path ) {
You can’t perform that action at this time.
0 commit comments