Repository navigation
ppd-collection: close the archive handle before returning on temp-fd failure - #126
Merged
tillkamppeter merged 1 commit intoNov 26, 2026
Conversation
…failure Both ppdCollectionGetPPD()'s dynamic-driver-program branch and cat_tar() open the PPD's source (a PipeCommand() pipe or an archive file, respectively) before creating a temporary file to copy the extracted PPD into. When cupsCreateTempFd() fails (e.g. a full or unwritable /tmp, or the process being out of file descriptors), both functions logged the error and returned NULL immediately without closing that already-open handle first -- every other error path in each function (read error, write error, "not found") already closes it correctly, this one case just didn't. Close the pipe (via ClosePipeCommand(), matching every other exit from that branch) and the archive file (via cupsFileClose(), matching every other exit from cat_tar()) before returning on this path too.
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.
What
Both
ppdCollectionGetPPD()'s dynamic-driver-program branch andcat_tar()open the PPD's source (aPipeCommand()pipe or an archive file, respectively) before creating a temporary file to copy the extracted PPD into. WhencupsCreateTempFd()fails (e.g. a full or unwritable/tmp, or the process being out of file descriptors), both functions logged the error and returnedNULLimmediately without closing that already-open handle first — every other error path in each function (read error, write error, "not found") already closes it correctly, this one case just didn't.Fix
Close the pipe (via
ClosePipeCommand(), matching every other exit from that branch) and the archive file (viacupsFileClose(), matching every other exit fromcat_tar()) before returning on this path too.Testing
Cherry-picked cleanly onto current upstream/master; confirmed via direct source inspection that both target sites still carry the unpatched pattern there (a third, similar-looking log message elsewhere in the file belongs to an unrelated, already-safe code path).