Repository navigation
ppd-collection: check malloc before copying into it - #117
Merged
tillkamppeter merged 1 commit intoNov 21, 2026
Merged
tillkamppeter merged 1 commit into
tillkamppeter merged 1 commit into
Conversation
Two spots allocate a small record with malloc() and immediately memcpy() into the result without checking for NULL: ppdCollectionListPPDs() when copying a matched PPD record for the caller, and load_ppds()'s directory-loop-detection bookkeeping. Both are on the normal path of listing/scanning a PPD collection (e.g. "cups-driverd list" on a Printer Application's PPD database), so an allocation failure there is currently a NULL-pointer memcpy rather than a clean error. ppdCollectionListPPDs() logs and stops adding further PPDs to the result it already built; load_ppds() logs and returns failure, since it can no longer safely track this directory for loop detection.
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
Two spots in
ppd-collection.cxxallocate a small record withmalloc()and immediatelymemcpy()into the result without checking for NULL:ppdCollectionListPPDs(), when copying a matched PPD record for the caller.load_ppds()'s directory-loop-detection bookkeeping.Both are on the normal path of listing/scanning a PPD collection (e.g.
cups-driverd liston a Printer Application's PPD database), so an allocation failure there is currently a NULL-pointermemcpyrather than a clean error.Fix
ppdCollectionListPPDs(): on failure, log and stop adding further PPDs to the result array it already built (returning what it has so far rather than crashing).load_ppds(): on failure, log and return failure, since it can no longer safely track this directory for loop detection.Both follow the existing
calloc(...) == NULLerror-logging pattern already used elsewhere in this same file.Test plan