nilsteampassnet / TeamPass

Collaborative Passwords Manager
https://www.teampass.net
1.67k stars 546 forks source link

Infinite loop when upgrading to 3.1.2.114 #4365

Closed gonzalodeniz closed 1 month ago

gonzalodeniz commented 1 month ago

Steps to reproduce

  1. Upgrade from 3.1.2.90 to 3.1.2.114

Expected behaviour

Successful completion of the upgrade

Actual behaviour

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) in /var/www/html/teampass/sources/main.functions.php on line 2163

Server configuration

Operating system: ubuntu 22.04

Web server: apache 2.4

Database: MariaDB10

PHP version: 8.2

Teampass version: 3.1.2.114

Logs

Web server error log

[Wed Sep 25 15:01:19.075671 2024] [php:error] [pid 14] [client 172.xx.xx.xx:42030] PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) in /var/www/html/teampass/sources/main.functions.php on line 2163, referer: http://localhost:3080/teampass/install/upgrade.php

Log from the web-browser developer console (CTRL + SHIFT + i)

Nothing

I think the error is in this recursive function that does not stop:

source/main.functions.php

Line: 2141 function recursiveChmod( string $path, int $filePerm = 0644, int $dirPerm = 0755 )

Is there any news on this point?

gonzalodeniz commented 1 month ago

When I have an opening, I'll make a trace.

gonzalodeniz commented 1 month ago

The recursiveChmod function has an error.

Here is a trace (I remove non-relevant variables):

# There is a path in the code that is ‘install/install’.
# $path=‘install/install’
recursiveChmod($path, $filePerm, $dirPerm)  {          

# basename extracts the last part of the route
$path = basename($path);        # $path=‘install’; 
...
} elseif (is_dir($path)) {                # is_dir(‘install’) = True 

# scandir(‘install’) extracts the contents of ‘/install’, not ‘install/install’.
# One of the elements returned is again ‘install’.
$foldersAndFiles = scandir($path);       

# Start again at the same place. Infinite loop.
# $path/$entry = 'install/install'
recursiveChmod($path.‘/’.$entry, $filePerm, $dirPerm);

Does it work for you?

gonzalodeniz commented 1 month ago

The solution is to rename or delete the second install folder:

mv install/install install/install_disable
gonzalodeniz commented 1 month ago

Fixed in v3.1.2.120