Skip to content

ppd-collection: close the archive handle before returning on temp-fd failure - #126

Merged
tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix-cat-tar-tempfd-fail-leaks-archive-fp-v2
Nov 26, 2026
Merged

tillkamppeter merged 1 commit into
OpenPrinting:masterfrom
ManasBagul23:fix-cat-tar-tempfd-fail-leaks-archive-fp-v2

Conversation

@ManasBagul23

Copy link
Copy Markdown
Contributor

What

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.

Fix

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.

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).

…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.
@tillkamppeter
tillkamppeter merged commit 48fb146 into OpenPrinting:master Nov 26, 2026
15 checks passed
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.

2 participants