Skip to content

Bound charset detector lookahead - #44

Open
acts-1631 wants to merge 1 commit into
tarot231:mainfrom
acts-1631:security-charset-lookahead
Open

Bound charset detector lookahead#44
acts-1631 wants to merge 1 commit into
tarot231:mainfrom
acts-1631:security-charset-lookahead

Conversation

@acts-1631

Copy link
Copy Markdown

Charset detection reads one byte beyond the NUL terminator when a multibyte sequence ends at a lead byte. A crafted file can trigger a heap out-of-bounds read during automatic charset detection, potentially crashing Leafpad.

This adds a helper that checks for the NUL terminator before each multibyte lookahead across the Chinese, Japanese, Korean, and escape-sequence detectors.

Validated with ASan and truncated-byte sweeps across the affected locale paths.

Charset detection advanced past the NUL terminator when a multibyte

sequence ended at a lead byte. This allowed truncated file contents to

trigger a heap out-of-bounds read.

Check for the terminator before each detector lookahead so incomplete

sequences stop without reading beyond the input buffer.
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