]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add a write check in cupsFileOpen/Fd (Issue #1360)
authorMichael R Sweet <msweet@msweet.org>
Thu, 11 Sep 2025 14:47:20 +0000 (10:47 -0400)
committerMichael R Sweet <msweet@msweet.org>
Thu, 11 Sep 2025 14:47:24 +0000 (10:47 -0400)
CHANGES.md
cups/file.c

index 7a3179515d19cf74b7b7e6fd8c5366c16a2562ab..72b60d895bd2b151d53562ac7b9bfdd767d3feb1 100644 (file)
@@ -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/`)
index c4293fc2e9d9c24baf99ffdc96a07f4c8969f322..37a0301e79ae0be20ab0451cc46a62068df5a389 100644 (file)
@@ -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);
           }