Skip to content

Zero hdrtoken heap to fix use-of-uninitialized-value#13172

Merged
shukitchan merged 1 commit into
apache:masterfrom
shukitchan:fix/hdrtoken-uninit-heap
May 18, 2026
Merged

Zero hdrtoken heap to fix use-of-uninitialized-value#13172
shukitchan merged 1 commit into
apache:masterfrom
shukitchan:fix/hdrtoken-uninit-heap

Conversation

@shukitchan
Copy link
Copy Markdown
Contributor

The hdrtoken heap allocated in hdrtoken_init() leaves padding bytes between each token's null terminator and the next prefix slot uninitialized, since ink_strlcpy only writes strlen+1 bytes but heap_ptr advances by sstr_len (rounded up to sizeof(HdrTokenHeapPrefix)). Switch to ats_calloc so the padding bytes are zeroed.

This fixes the reported fuzzing issues
https://oss-fuzz.com/testcase-detail/4669620266270720

The hdrtoken heap allocated in hdrtoken_init() leaves padding bytes
between each token's null terminator and the next prefix slot
uninitialized, since ink_strlcpy only writes strlen+1 bytes but
heap_ptr advances by sstr_len (rounded up to sizeof(HdrTokenHeapPrefix)).
Switch to ats_calloc so the padding bytes are zeroed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shukitchan shukitchan added this to the 11.0.0 milestone May 18, 2026
@shukitchan shukitchan self-assigned this May 18, 2026
@shukitchan shukitchan requested a review from Copilot May 18, 2026 20:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an OSS-Fuzz “use-of-uninitialized-value” report in ATS header token initialization by ensuring the heap used to store token strings has its padding bytes zero-initialized.

Changes:

  • Replace ats_malloc(heap_size) with ats_calloc(1, heap_size) for _hdrtoken_strs_heap_f allocation in hdrtoken_init(), zeroing padding bytes between strings.

@shukitchan shukitchan merged commit e57901c into apache:master May 18, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants