Skip to content

fix(stse_generate_random): fix overflow and improve documentation#87

Merged
TofMassilia13320 merged 2 commits into
STMicroelectronics:mainfrom
parmi93:patch-2
Jun 5, 2026
Merged

fix(stse_generate_random): fix overflow and improve documentation#87
TofMassilia13320 merged 2 commits into
STMicroelectronics:mainfrom
parmi93:patch-2

Conversation

@parmi93
Copy link
Copy Markdown
Contributor

@parmi93 parmi93 commented May 30, 2026

Changes

Bug fix

The previous implementation incremented the index by STSAFEA_MAXIMUM_RNG_SIZE even for the last chunk, which could cause an integer overflow and potentially an infinite loop when random_size is close to UINT16_MAX.

Replaced index-based iteration with pointer arithmetic and random_size decrement to avoid overflow. Added early return STSE_OK for random_size == 0.

Documentation

Fixed incorrect Doxygen tag for random_size parameter from [in,out] to [in].

parmi93 added 2 commits May 30, 2026 15:30
…rement

The previous implementation incremented the index by STSAFEA_MAXIMUM_RNG_SIZE
even for the last chunk, which could cause an integer overflow and potentially
an infinite loop when random_size is close to UINT16_MAX.

Replaced index-based iteration with pointer arithmetic and random_size
decrement to avoid overflow. Added early return STSE_OK for random_size == 0.
@TofMassilia13320 TofMassilia13320 merged commit c478e4e into STMicroelectronics:main Jun 5, 2026
1 check passed
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.

2 participants