Skip to content

Avoid 32-bit shift overflow when computing alignment in ReportCorruptedFree. - #1793

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1011015766
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1011015766

Conversation

@copybara-service

Copy link
Copy Markdown

Avoid 32-bit shift overflow when computing alignment in ReportCorruptedFree.

ReportCorruptedFree computed pointer alignment as 1u << absl::countr_zero(reinterpret_cast<uintptr_t>(ptr)). When a corrupted pointer is >= 4 GiB-aligned (countr_zero >= 32) on 64-bit platforms, shifting a 32-bit 1u literal invokes undefined behavior and reports got alignment 1. Use uintptr_t{1} << ... in both ReportCorruptedFree overloads.

…edFree.

`ReportCorruptedFree` computed pointer alignment as `1u << absl::countr_zero(reinterpret_cast<uintptr_t>(ptr))`. When a corrupted pointer is `>= 4 GiB`-aligned (`countr_zero >= 32`) on 64-bit platforms, shifting a 32-bit `1u` literal invokes undefined behavior and reports `got alignment 1`. Use `uintptr_t{1} << ...` in both `ReportCorruptedFree` overloads.

PiperOrigin-RevId: 1011015766

This branch has not been deployed

No deployments
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