From: Michael R Sweet Date: Thu, 11 Sep 2025 14:47:20 +0000 (-0400) Subject: Add a write check in cupsFileOpen/Fd (Issue #1360) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=213c7412901db761adf88813ae5093d3e9b35c7b;p=thirdparty%2Fcups.git Add a write check in cupsFileOpen/Fd (Issue #1360) --- diff --git a/CHANGES.md b/CHANGES.md index 7a3179515d..72b60d895b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -151,6 +151,7 @@ Changes in CUPS v2.5b1 (YYYY-MM-DD) - Fixed job cleanup after daemon restart (Issue #1315) - Fixed unreachable block in IPP backend (Issue #1351) - Fixed memory leak in _cupsConvertOptions (Issue #1354) +- Fixed missing write check in `cupsFileOpen/Fd` (Issue #1360) - Removed hash support for SHA2-512-224 and SHA2-512-256. - Removed `mantohtml` script for generating html pages (use `https://www.msweet.org/mantohtml/`) diff --git a/cups/file.c b/cups/file.c index c4293fc2e9..37a0301e79 100644 --- a/cups/file.c +++ b/cups/file.c @@ -1080,12 +1080,15 @@ cupsFileOpenFd(int fd, // I - File descriptor header[8] = 0; header[9] = 0x03; - cups_write(fp, (char *)header, 10); + if (cups_write(fp, (char *)header, 10) < 10) + { + free(fp); + return (NULL); + } // Initialize the compressor... if (deflateInit2(&(fp->stream), mode[1] - '0', Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) < Z_OK) { - close(fd); free(fp); return (NULL); }