operasoftware / dns-ui

Opera's LDAP-authenticated PowerDNS user interface
Apache License 2.0
282 stars 57 forks source link

"Export zone in bind9 format" memory usage #183

Closed tacerus closed 3 years ago

tacerus commented 3 years ago

Hi,

I already increased the memory limit in my PHP 8 FPM server to 1024M, but trying to export a zone with about 30 records still exhausts it: <b>Fatal error</b>: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 536870920 bytes) in <b>/path/to/my/webroot/dnsui1/core.php</b> on line <b>367</b><br />

Is this expected? I feel like this might be a memory leak, however am not good enough with PHP code to investigate.

Cheers Georg

tacerus commented 3 years ago

EDIT: Seems to only be an issue in PHP 8. Using DNS UI with a PHP 7 FPM server, the issue does not exist, and the default memory_limit suffices.

thomas-pike commented 3 years ago

It definitely shouldn't need a gigabyte to import a 30 record zone. Seems like it must be stuck in an infinite loop to reach that kind of level.

tacerus commented 3 years ago

Ye, on PHP7 it works fine with a limit of 256M.

nhulsch commented 3 years ago

PHP 8.0 changed the type of mb_strcut when there is nothing left.

Changing line 364 in core.php should fix it, please try.

from: while($content !== false) {

to: while(mb_strlen($content) != 0) {

thomas-pike commented 3 years ago

Thank you for identifying the problem and providing a fix. I've pushed a commit with this fix in now.

tacerus commented 2 years ago

Thank you so much, @nhulsch!