Skip to content

Update a couple of functions to know buffer length - #121

Open
hjmjohnson wants to merge 1 commit into
masterfrom
missing-buffer-len
Open

hjmjohnson wants to merge 1 commit into
masterfrom
missing-buffer-len

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Re-submission of #21, 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
  • ENH: Bound the field-modification helpers by the destination size

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

modify_all_fields() and modify_field() wrote into a caller-supplied
buffer at an offset taken from the field table, with no way to check that
the write stayed inside it. Both now take the buffer size, and
modify_field() rejects a field whose offset plus size * len exceeds it.

The check sits ahead of the switch, so it covers every write path rather
than the string case alone, and it reports and returns like the other
failures in the function; an assert() would compile away in the release
builds that ship.

No field table can trip it today: check_total_size() already requires the
offsets to tile the structure exactly. It bounds future edits to them.

(cherry picked from commit 7356eb1)
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.

2 participants