From 5c3048d4965d437f511267f9f3d961b15dc4487f Mon Sep 17 00:00:00 2001
From: Michael R Sweet <msweet@msweet.org>
Date: Thu, 16 Apr 2026 12:59:12 -0400
Subject: [PATCH] Fix regression in cupsRasterRead/WriteHeader.

---
 cups/raster-stream.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/cups/raster-stream.c
+++ b/cups/raster-stream.c
@@ -1572,7 +1572,8 @@ cups_raster_read(cups_raster_t *r,	/* I
 static int				/* O - 1 on success, 0 on failure */
 cups_raster_update(cups_raster_t *r)	/* I - Raster stream */
 {
-  int	ret = 1;			/* Return value */
+  int		ret = 1;		/* Return value */
+  unsigned	bytesPerLine;		/* Expected bytes per line */
 
 
   if (r->sync == CUPS_RASTER_SYNCv1 || r->sync == CUPS_RASTER_REVSYNCv1 ||
@@ -1697,6 +1698,10 @@ cups_raster_update(cups_raster_t *r)	/*
     ret = 0;
   }
 
+  bytesPerLine = (r->header.cupsWidth * r->header.cupsBitsPerPixel + 7) / 8;
+  if (r->header.cupsColorOrder == CUPS_ORDER_BANDED)
+    bytesPerLine *= r->header.cupsNumColors;
+
   if (r->header.cupsBytesPerLine == 0)
   {
     _cupsRasterAddError("Invalid raster line length 0.");
@@ -1712,7 +1717,7 @@ cups_raster_update(cups_raster_t *r)	/*
     _cupsRasterAddError("Raster line length %u is not a multiple of the pixel size (%d).", r->header.cupsBytesPerLine, r->bpp);
     ret = 0;
   }
-  else if (r->header.cupsBytesPerLine != ((r->header.cupsWidth * r->header.cupsBitsPerPixel + 7) / 8))
+  else if (r->header.cupsBytesPerLine != bytesPerLine)
   {
     _cupsRasterAddError("Raster line length %u does not match width (%u) and bits per pixel (%u).", r->header.cupsBytesPerLine, r->header.cupsWidth, r->header.cupsBitsPerPixel);
     ret = 0;
