pi-hole / web

Pi-hole Dashboard for stats and more
https://pi-hole.net
Other
2.02k stars 560 forks source link

Division by 0 in header_authenticated.php #3154

Open enginelesscc opened 5 hours ago

enginelesscc commented 5 hours ago

Info

I initially wanted to open a PR but the guidelines got me a bit unsure given this affects v5 only while v6 is lua now and doesnt have the affected code..

But I found it may still be useful to post for anyone currently affected until v6 is released.

The simple fix for this is here:

pi-hole/web/commit/bbcf9fa857002010d3c61c04f90a35ec6c31cea2

Versions

Platform

Expected behavior

Functional Webinterface / data validation

Actual behavior / bug

/proc/meminfo may return no data in a linux container (in my case: incus), causing the $data array to be incomplete. This resulted in a division by 0 error trying to divide by non-existant $meminfo['MemTotal']. This meant pihole-web was unusable (error 500).

Steps to reproduce

n/A

Debug Token

n/A

Screenshots

n/A

Additional context

n/A

rdwebdesign commented 2 hours ago

Thank you for the information.

Reading the code, it's obvious that a "Division by 0" will happen if $meminfo['MemTotal'] is zero (nice catch), but to be honest, you are probably the only user facing this issue, because we've never received similar complaints.

It is very unlikely that there will be another v5 release. As you noticed, the current code in development branch is for Pi-hole v6.

I will keep this issue open until we release v6, so other users can use your fix, if needed.


Why did you change line 44? This is not needed to fix the issue and I don't think it will be possible to have less than 4 lines if /proc/meminfo exists.