Fix heap corruption via callback signature mismatch in cfFilterPCLmToRaster#171
Merged
tillkamppeter merged 1 commit intoJul 23, 2026
Conversation
process_image() was declared with 5 parameters but cast to pdfio_dict_cb_t (3 parameters) at line 1035. When invoked by pdfioDictIterateKeys(), the 4th and 5th parameters (pixel_count, bitmap) received undefined register values, causing realloc() on a garbage pointer and memcpy() to an arbitrary address. Fix: move pixel_count and bitmap into pclmtoraster_data_t and change process_image() to match the pdfio_dict_cb_t signature (3 parameters), eliminating the dangerous cast entirely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
process_image()incupsfilters/pclmtoraster.cwas declared with 5 parameters but cast topdfio_dict_cb_t(a 3-parameter callback type) at line 1035. When invoked bypdfioDictIterateKeys(), the 4th and 5th parameters (pixel_count,bitmap) received undefined CPU register values. The function then calledrealloc()on the garbagebitmappointer andmemcpy()to write image data to the resulting address — guaranteed heap corruption/crash on any PCLm input with XObject images.Root Cause
Fix
pixel_countandbitmapintopclmtoraster_data_tstruct (they were local variables inout_page()that could never reachprocess_image()through the callback interface anyway)process_image()signature to matchpdfio_dict_cb_t(3 parameters:dict,key,void *cb_data)(pdfio_dict_cb_t)cast entirelyinit_pclmtoraster_data_t()and at the call siteImpact
Without this fix, any PCLm file processed through
cfFilterPCLmToRasterthat contains XObject images causes heap corruption viarealloc(garbage_pointer, ...)andmemcpy(garbage_address, ...). Reachable via network printing (IPP/LPD).Related