read_cgi_config_file() fails after upgrading to PHP 8.0

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
leres
Posts: 7
Joined: Wed Feb 22, 2017 10:16 pm

read_cgi_config_file() fails after upgrading to PHP 8.0

Post 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.
Attachments
patch.txt
patch
(436 Bytes) Downloaded 570 times
Locked