Skip to content

BUG: Stop loc_strnlen reading one byte past the buffer it is given - #103

Open
hjmjohnson wants to merge 1 commit into
masterfrom
fix/axml-strnlen-bound
Open

hjmjohnson wants to merge 1 commit into
masterfrom
fix/axml-strnlen-bound

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Re-submission of #66, reverted from master on 2026-09-24 so it can be
reviewed before merging. Content is unchanged from the original.

Base: master. Independent: nothing has to land before it.

Commits
  • BUG: Stop loc_strnlen reading one byte past the buffer it is given

Ordering for all the re-submitted work is tracked in #84.

loc_strnlen measures a string that need not be terminated, but it
dereferences before testing the bound, so when no NUL appears in the
first maxlen bytes the last iteration reads str[maxlen].

Both callers pass an unterminated buffer: axml_read_buf takes the
caller's buffer and its length, and axml_read_file measures what
fread returned, which fills the buffer for any larger file.

AddressSanitizer on a buffer sized to its content reports a
heap-buffer-overflow read 0 bytes after a 324-byte region. The
returned length is unchanged wherever the old order was in bounds.

(cherry picked from commit 7476a12)
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.

3 participants