Skip to content

Add missing length check to png_handle_tIME; remove dead PNG_UNUSED(length) - #866

Open
XananasX7 wants to merge 1 commit into
pnggroup:libpng18from
XananasX7:fix/handle-tIME-missing-length-check
Open

XananasX7 wants to merge 1 commit into
pnggroup:libpng18from
XananasX7:fix/handle-tIME-missing-length-check

Conversation

@XananasX7

Copy link
Copy Markdown

Summary

Add the missing length guard to png_handle_tIME() in pngrutil.c, and remove the dead PNG_UNUSED(length) statement that follows an unconditional return.

Problem

Every other fixed-size chunk handler in pngrutil.c validates the chunk length before reading data, for example png_handle_tRNS, png_handle_bKGD, png_handle_gAMA:

if (length != expected)
{
   png_crc_finish(png_ptr, length);
   png_chunk_benign_error(png_ptr, "invalid");
   return handled_error;
}

png_handle_tIME is the only fixed-size handler that skips this check and calls png_crc_read(png_ptr, buf, 7) unconditionally. The dispatch layer (CDtIME 7U, 7U) currently rejects wrong-length chunks before reaching the handler, so there is no direct exploitable path — but relying solely on the dispatch layer for safety is fragile and inconsistent.

Additionally, PNG_UNUSED(length) appears after return handled_ok at the end of the function body, making it dead code.

Fix

  1. Add the explicit length check after the debug trace, matching every other handler.
  2. Remove the dead PNG_UNUSED(length) macro invocation.

Fixes #826.

@XananasX7

Copy link
Copy Markdown
Author

Friendly ping - this adds the missing length check to png_handle_tIME. Happy to revise if the maintainers have any feedback.

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.

png_handle_tIME: missing length check

1 participant