]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add additional parameter validation to _cupsRasterWritePixels 914/head
authorBenjamin Gordon <bmgordon@chromium.org>
Mon, 25 Mar 2024 15:59:21 +0000 (09:59 -0600)
committerBenjamin Gordon <bmgordon@chromium.org>
Mon, 25 Mar 2024 16:23:04 +0000 (10:23 -0600)
If len is 0, the function does a lot of calculations that ultimately
don't produce any output.  This can be skipped with an early return.

If cupsBytesPerLine is 0, this triggers a divide by zero if the output
isn't compressed.  This is an error on the caller's part, but it's
nicer to return an error than to crash.

cups/raster-stream.c

index d64eefcefc4c6a4cb19207898103c7363caa54a4..f130670097b7a6df8591071eadaf1b0617713c8a 100644 (file)
@@ -1407,7 +1407,7 @@ _cupsRasterWritePixels(
 
   DEBUG_printf("_cupsRasterWritePixels(r=%p, p=%p, len=%u), remaining=%u", (void *)r, (void *)p, len, r->remaining);
 
-  if (r == NULL || r->mode == CUPS_RASTER_READ || r->remaining == 0)
+  if (r == NULL || r->mode == CUPS_RASTER_READ || r->remaining == 0 || len == 0 || r->header.cupsBytesPerLine == 0)
     return (0);
 
   if (!r->compressed)