Skip to content

Conversation

@MegaManSec
Copy link
Contributor

Make DISCARD sticky. If state is DISCARD, drop subsequent chunks early.

When switching to DISCARD, free buffer and reset alloc and used to 0.

Fix 1 byte OOB write caused by talloc_bstr_realloc semantics on NULL. Allocate space for data plus the trailing NUL. For non NULL buffers request needed - 1 since bstr adds the NUL. For NULL buffers request full needed since bstr allocates exactly inlen bytes (no + 1).

Prevent uninitialized data exposure after DISCARD by clearing stale used when buffer is NULL before writing.

Always NUL terminate at buffer[used].

This removes the truncated tail return, prevents reading uninitialized bytes, and eliminates the off by one write on first allocation.

This bug was found with ZeroPath.

Make DISCARD sticky. If state is DISCARD, drop subsequent chunks early.

When switching to DISCARD, free buffer and reset alloc and used to 0.

Fix 1 byte OOB write caused by talloc_bstr_realloc semantics on NULL.
Allocate space for data plus the trailing NUL. For non NULL buffers
request needed - 1 since bstr adds the NUL. For NULL buffers request
full needed since bstr allocates exactly inlen bytes (no + 1).

Prevent uninitialized data exposure after DISCARD by clearing stale
used when buffer is NULL before writing.

Always NUL terminate at buffer[used].

This removes the truncated tail return, prevents reading uninitialized
bytes, and eliminates the off by one write on first allocation.

This bug was found with ZeroPath.

Signed-off-by: Joshua Rogers <[email protected]>
@MegaManSec
Copy link
Contributor Author

By the way, it is kind of surprising that talloc_bstr_realloc() will not include a byte for a nul-terminator if passed as NULL in.

Signed-off-by: Joshua Rogers <[email protected]>
@alandekok
Copy link
Member

By the way, it is kind of surprising that talloc_bstr_realloc() will not include a byte for a nul-terminator if passed as NULL in.

Yeah, that seems odd. I'll take a look.

@arr2036
Copy link
Member

arr2036 commented Oct 29, 2025

Alan correct the behaviour of talloc_bstr_realloc, can you rework this PR to account for that.

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