HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Server Operation (http://www.howtoforge.com/forums/forumdisplay.php?f=5)
-   -   Infinite loop caused by a crappy code in PHP (http://www.howtoforge.com/forums/showthread.php?t=56116)

holykim 10th February 2012 03:42

Infinite loop caused by a crappy code in PHP
 
Hi

Due to crappy code by one of my users, PHP entered an infinite loop generating an error, causing very high load on the server and gigantic log files.

Unfortunately the fail2ban gets taking 100% CPU too with the log files which increasing more and more.

I did set ignore_repeated_errors to On, as well as ignore_repeated_source in php.ini. I checked that the settings is effective in phpinfo() but it doesn't help.

Is there anyone can help me to be able to keep the server resources from this kind of crappy code?

I am running ISPConfig 3 on CentOS

Thanks

till 10th February 2012 09:19

You can e.g. reduce the max execution time in php.ini.

holykim 10th February 2012 10:12

Hi Till

Thank you for your reply.

A log file is being increased as several hundreds megabyte in 10~20 seconds. Also the error won't be stopped by max_execution_time.

For example, the zip.db file doesn't exist in the code below, PHP will generate gigantic log files and won't be stopped itself. Just imagine that people open the webpage at the same time.... Please advise.

PHP Code:

$fp fopen("./zip.db""r");
while(!
feof($fp)) {
    
$zipfile[] = fgets($fp4096);



till 10th February 2012 10:48

There are severaloptions, if the errors are no fatal errors, then you might change the error_reporting level to include only fatal errors and not e.g. warnings in the log. Another option can be to turn of php error logging and display errors only in the webpage or you define a separate error_log for php in php.ini which is not monitored by fail2ban.


All times are GMT +2. The time now is 23:16.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.