Skip to content

Add bounds check before word32 cast - #12005

Open
rlm2002 wants to merge 2 commits into
wolfSSL:masterfrom
rlm2002:fenrir10635
Open

rlm2002 wants to merge 2 commits into
wolfSSL:masterfrom
rlm2002:fenrir10635

Conversation

@rlm2002

@rlm2002 rlm2002 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

On a 64-bit build, an outlen of exactly 2^32 is treated as 0. Add bounds check before (word32)outlen cast in wolfSSL_FIPS_drbg_generate() to prevent unintentional success.

Fixes F-10635

Testing

./configure --enable-opensslall && make && ./tests/unit.test -1814

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Copilot AI balanced review requested due to automatic review settings November 4, 2026 23:37
@rlm2002 rlm2002 self-assigned this Nov 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the output-length truncation fix.

No open issues 🎉

What changed in this PR

This PR prevents wolfSSL_FIPS_drbg_generate() from reporting unintended success when a large size_t output length truncates to zero during conversion to word32.

Changes:

  • Reject output lengths that exceed the maximum word32 value before casting.
  • Add a regression test for a length of 2³² on platforms with wider size_t, checking failure and an unchanged output buffer.
File Description
tests/​api.c Adds regression coverage for output-length truncation.
src/​ssl.c Checks the output-length bound before conversion to word32.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

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