Skip to content

Commit c9e70b2

Browse files
committed
Fix page header validation for banded raster data.
1 parent 5c53144 commit c9e70b2

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ v3.0.2 - YYYY-MM-DD
99
- Fixed a recursion issue with encoding of nested collections.
1010
- Fixed a potential margin issue when generating A4 PCL from `ipptransform`.
1111
- Fixed exporting of JSON with very large numbers.
12+
- Fixed page header validation in `cupsRasterReadHeader` and
13+
`cupsRasterWriteHeader` for banded raster data.
1214

1315

1416
v3.0.1 - 2026-04-09

cups/raster-stream.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,8 @@ cups_raster_read(cups_raster_t *r, // I - Raster stream
15571557
static bool // O - `true` on success, `false` on failure
15581558
cups_raster_update(cups_raster_t *r) // I - Raster stream
15591559
{
1560-
bool ret = true; // Return value
1560+
bool ret = true; // Return value
1561+
unsigned bytesPerLine; // Expected bytes per line
15611562

15621563

15631564
if (r->sync == CUPS_RASTER_SYNCv1 || r->sync == CUPS_RASTER_REVSYNCv1 ||
@@ -1686,6 +1687,10 @@ cups_raster_update(cups_raster_t *r) // I - Raster stream
16861687
ret = false;
16871688
}
16881689

1690+
bytesPerLine = (r->header.cupsWidth * r->header.cupsBitsPerPixel + 7) / 8;
1691+
if (r->header.cupsColorOrder == CUPS_ORDER_BANDED)
1692+
bytesPerLine *= r->header.cupsNumColors;
1693+
16891694
if (r->header.cupsBytesPerLine == 0)
16901695
{
16911696
_cupsRasterAddError("Invalid raster line length 0.");
@@ -1701,7 +1706,7 @@ cups_raster_update(cups_raster_t *r) // I - Raster stream
17011706
_cupsRasterAddError("Raster line length %u is not a multiple of the pixel size (%d).", r->header.cupsBytesPerLine, r->bpp);
17021707
ret = false;
17031708
}
1704-
else if (r->header.cupsBytesPerLine != ((r->header.cupsWidth * r->header.cupsBitsPerPixel + 7) / 8))
1709+
else if (r->header.cupsBytesPerLine != bytesPerLine)
17051710
{
17061711
_cupsRasterAddError("Raster line length %u does not match width (%u) and bits per pixel (%u).", r->header.cupsBytesPerLine, r->header.cupsWidth, r->header.cupsBitsPerPixel);
17071712
ret = false;

0 commit comments

Comments
 (0)