Skip to content

Fix out-of-bounds read in VoiceKit::load_buf_()#553

Open
teancom wants to merge 2 commits intoesphome:devfrom
teancom:fix/load-buf-oob-read
Open

Fix out-of-bounds read in VoiceKit::load_buf_()#553
teancom wants to merge 2 commits intoesphome:devfrom
teancom:fix/load-buf-oob-read

Conversation

@teancom
Copy link
Copy Markdown
Contributor

@teancom teancom commented Feb 22, 2026

The copy loop used max_len (128) as its bound instead of buf_len (the actual number of remaining bytes), reading past the end of firmware_bin_ on the final chunk. Also fix the offset guard to reject offset == firmware_bin_length_ where zero bytes remain. Replace byte-by-byte loop with memcpy, which the compiler can optimize to word-sized copies.

Note that, even though we were reading past the bounds we just dropped the extra bytes without using them. This is a correctness and (tiny) speed-up thing, not a security / safety thing.

teancom and others added 2 commits February 21, 2026 20:13
The copy loop used max_len (128) as its bound instead of buf_len (the
actual number of remaining bytes), reading past the end of firmware_bin_
on the final chunk. Also fix the offset guard to reject offset ==
firmware_bin_length_ where zero bytes remain. Replace byte-by-byte loop
with memcpy, which the compiler can optimize to word-sized copies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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