Skip to content

lib: fix nearest_power() overflow handling on 32-bit platforms#284

Open
uwezkhan wants to merge 1 commit intodovecot:mainfrom
uwezkhan:nearest-power-overflow-fix
Open

lib: fix nearest_power() overflow handling on 32-bit platforms#284
uwezkhan wants to merge 1 commit intodovecot:mainfrom
uwezkhan:nearest-power-overflow-fix

Conversation

@uwezkhan
Copy link
Copy Markdown
Contributor

@uwezkhan uwezkhan commented May 2, 2026

On 32-bit platforms, nearest_power() may return an undersized value
for inputs larger than the maximum representable power of two.

This can cause callers to receive a buffer smaller than requested when
rounding large allocation sizes.

Reject overflow-range inputs explicitly so nearest_power() never
returns a value smaller than the requested size.

This change preserves the existing nearest_power(0) == 1 behavior and
adds regression tests covering overflow-range inputs.

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