Page 1 of 1

read_cgi_config_file() fails after upgrading to PHP 8.0

Posted: Sat Feb 06, 2021 2:04 pm
by leres
I'm using nagios 4.4.6 on FreeBSD 12.2-RELEASE and just upgraded from PHP 7.4 to 8.0. Trying to load the main nagios index.php results in:

Code: Select all

Warning: Trying to access array offset on value of type bool in /usr/local/www/nagios/includes/utils.inc.php on line 217
read_cgi_config_file() is looping on !feof() but debugging shows that after the last line of the file is read, feof() still returns FALSE even though the file handle is positioned at EOF and when fgets() is called it return FALSE (and we die).

I suspect there is a bug with php 8.0 where feof() doesn't return TRUE until after a fgets() is called and returns FALSE.

Here's a minimal patch.