From e52f97acf3f438277979b56267a8393cd7326470 Mon Sep 17 00:00:00 2001 From: ManasBagul23 Date: Sat, 21 Nov 2026 00:10:22 +0530 Subject: [PATCH] ppd-collection: close the archive handle before returning on temp-fd 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. --- ppd/ppd-collection.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ppd/ppd-collection.cxx b/ppd/ppd-collection.cxx index 3125fa27..7159553a 100644 --- a/ppd/ppd-collection.cxx +++ b/ppd/ppd-collection.cxx @@ -788,6 +788,7 @@ ppdCollectionGetPPD( "libppd: [PPD Collections] Unable to copy PPD to temp " "file: %s", strerror(errno)); + ClosePipeCommand(fp, cpid, epid, log, ld); return (NULL); } while ((bytes = cupsFileRead(fp, buffer, sizeof(buffer))) > 0) @@ -1119,6 +1120,7 @@ cat_tar(const char *filename, // I - Archive name "libppd: [PPD Collections] Unable to copy PPD to temp " "file: %s", strerror(errno)); + cupsFileClose(fp); return (NULL); } for (total = 0; total < curinfo.st_size; total += bytes)