Skip to content

Fix heap-buffer-overflow write in PICT UnpackPictRow#41

Open
JorgeBarredo14 wants to merge 1 commit intodanoli3:masterfrom
JorgeBarredo14:fix/pict-packbits-oob-write
Open

Fix heap-buffer-overflow write in PICT UnpackPictRow#41
JorgeBarredo14 wants to merge 1 commit intodanoli3:masterfrom
JorgeBarredo14:fix/pict-packbits-oob-write

Conversation

@JorgeBarredo14
Copy link
Copy Markdown

Summary

The PackBits decompression loop in UnpackPictRow advances pCurPixel by the decoded run length without verifying that the destination remains within the allocated line buffer (pLineBuf, sized to rowBytes). A crafted PICT file with run lengths that exceed the scanline width causes memset (packed path) or read_proc (unpacked path) to write past the end of the buffer.

Root cause

PluginPICT.cpp lines 562 and 571: the decoded len is used directly in memset/read_proc without clamping to the remaining buffer space.

Fix

Clamp the decoded length to the remaining buffer space (pLineBuf + rowBytes - pCurPixel) before each write operation, in both the packed-data and unpacked-data code paths. Skip the write entirely if no space remains.

Metadata

  • CWE: CWE-787 (Out-of-bounds Write)
  • Severity: High
  • Reproducer: crafted PICT file (available on request)
  • Found during: academic security research

The PackBits decompression loop in UnpackPictRow advances
pCurPixel by the decoded run length without verifying that the
destination remains within the allocated line buffer. A crafted
PICT file with run lengths that exceed the scanline width causes
memset or read_proc to write past the end of pLineBuf.

Clamp the decoded length to the remaining buffer space before
each write operation, in both the packed-data and unpacked-data
code paths.

CWE-787 (Out-of-bounds Write)
Found during academic security research.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant