Skip to content

oss-fuzz: Keep the WRITE and STDIO options enabled - #989

Open
shubhs20 wants to merge 1 commit into
pnggroup:libpng16from
shubhs20:oss-fuzz-keep-write-stdio
Open

shubhs20 wants to merge 1 commit into
pnggroup:libpng16from
shubhs20:oss-fuzz-keep-write-stdio

Conversation

@shubhs20

@shubhs20 shubhs20 commented Nov 27, 2026 •

Copy link
Copy Markdown

contrib/oss-fuzz/build.sh has disabled the WRITE and STDIO options in pnglibconf.dfa since 2017. The libpng16.a that the OSS-Fuzz fuzzers link therefore contains no write support and no stdio functions, while the libpng that distributions ship has both. pngwrite.c, pngwutil.c, pngwtran.c, pngwio.c and the stdio entry points (png_init_io, png_image_begin_read_from_file/_stdio, png_image_write_to_file/_stdio) are not compiled in the fuzz build at all.

This change stops disabling WRITE and STDIO. Enabling STDIO would also enable CONSOLE_IO, with which libpng's default error and warning handlers print every message to stderr, so CONSOLE_IO is disabled instead: the four existing fuzzers are unchanged and stay as quiet as before. It is the prerequisite for fuzzing the write side (a follow-up PR will add a write fuzzer; the progressive reader is the subject of #946).

Effect, measured by comparing the source lines present in the debug line tables of the shipped library with the lines compiled by the OSS-Fuzz ASan build (the four console-output lines of png_default_error and png_default_warning, which this build no longer compiles, counted as not compiled):

  • Debian libpng16-16t64 1.6.59-1 (amd64): shipped lines not compiled by the fuzz build 3,112 -> 1,288 of 10,041 (functions 212 -> 100).
  • Fedora libpng 1.6.58-2.fc45 (x86_64): 3,158 -> 1,389 of 9,924.
  • The fixes for CVE-2025-64506 and CVE-2026-22801 are in png_image_write_main / png_write_image_8bit / png_write_image_16bit, which no OSS-Fuzz target compiled before this change.

Cost: no new dependencies; libpng16.a becomes larger (write objects are linked into the existing fuzzers because png.c references them); build time unchanged within noise.

Sanitizers: address, undefined and memory builds pass helper.py check_build; the change adds no dependency.

contrib/oss-fuzz/build.sh has disabled the WRITE and STDIO options in
pnglibconf.dfa since 2017, so the libpng16.a the fuzzers link has no
write support and no stdio functions, unlike the libpng that
distributions ship (where both are enabled).  pngwrite.c, pngwutil.c,
pngwtran.c and pngwio.c, and the stdio functions (png_init_io,
png_image_begin_read_from_file/_stdio, png_image_write_to_file/_stdio),
are therefore not compiled in the OSS-Fuzz build.

Stop disabling STDIO and WRITE.  With STDIO enabled, CONSOLE_IO would
be enabled too and libpng's default error and warning handlers would
print every message to stderr, so disable CONSOLE_IO instead: the
existing read fuzzers stay as quiet as before.  This is needed for
fuzzers of the write side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant