MantisBT - NetSurf
View Issue Details
0002846NetSurf[All Projects] Generalpublic2022-04-04 13:132024-02-25 21:41
ReporterPhilipRoman 
Assigned ToVincent Sanders 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionfixed 
Platformx86_64OSArtix LinuxOS Version
Product Version3.10 
Target Version3.11Fixed in Version3.11 
Fixed in CI build #5364
Reported in CI build #
URL of problem page
Summary0002846: Division by zero when there are images in cache but total size is zero.
DescriptionExactly what the title says.

I discovered this while trying to use man -H without psutils installed, which produced empty images. The bug is relatively harmless and almost impossible to come across in a real-life scenario but since netsurf works with untrusted input I thought it would be a good idea to patch it.
Steps To Reproducerun commands:
  touch empty.png
  echo '<img src="empty.png">' > test.html
  netsurf test.html
close browser
netsurf dumps core due to SIGFPE
Additional InformationSource file: content/handlers/image/image_cache.c
Function: image_cache_fini

op_size is zero but op_count is not:


if (op_count > 0) {
    ...
    NSLOG(netsurf, INFO,
      "Cache total/hit/miss/fail (size) ...",
      ...
      (image_cache->hit_size * 100) / op_size,
TagsNo tags attached.
Attached Files

Notes
(0002406)
Vincent Sanders   
2022-09-11 13:23   
ensured the logging did not attempt a divide by zero in this case
(0002431)
Vincent Sanders   
2024-02-25 21:40   
Issue resolved in 3.11 release
(0002432)
Vincent Sanders   
2024-02-25 21:41   
Issue resolved in 3.11 release

Issue History
2022-04-04 13:13PhilipRomanNew Issue
2022-09-11 13:23Vincent SandersAssigned To => Vincent Sanders
2022-09-11 13:23Vincent SandersStatusnew => resolved
2022-09-11 13:23Vincent SandersFixed in Version => 3.11
2022-09-11 13:23Vincent SandersTarget Version => 3.11
2022-09-11 13:23Vincent SandersFixed in CI build # => 5364
2022-09-11 13:23Vincent SandersNote Added: 0002406
2024-02-25 21:40Vincent SandersNote Added: 0002431
2024-02-25 21:41Vincent SandersStatusresolved => closed
2024-02-25 21:41Vincent SandersResolutionopen => fixed
2024-02-25 21:41Vincent SandersNote Added: 0002432