fix: replace uint8_t in for loops#5619
Merged
CarolYeh910 merged 1 commit intoaws:mainfrom Nov 17, 2025
Merged
Conversation
uint8_t in for loopuint8_t in for loops
maddeleine
approved these changes
Nov 17, 2025
jouho
approved these changes
Nov 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Prevent potential timeout in unit tests
Why
The for loops in
s2n_security_policy_get_version()ands2n_security_policy_supports_tls13()useuint8_t i = 0, which can only hold values from 0 to 255. Currently, s2n-tls has only 140 security policies, so everything is fine. However, as we add more policies in the future, the number of policies will eventually exceed the range ofuint8_t.Additionally, some unit tests define their own testing policies that do not exist in the
security_policy_selectionarray. In this case, the only way to exit these for loops is to hit thesecurity_policy_selection[i].version == NULLcondition (i.e. the last element insecurity_policy_selection). If the last policy withversion = NULLis out of range, these two for loops will become infinite and lead to timeout failure.How
Replace
uint8_twith another date type of a larger range likesize_tTesting
I found timeout failure in 25 s2n-tls unit tests by creating 120 copies of the
test_allpolicy and exceeding theuint8_trange. After applying the fix in this PR, all the timeout failures went away.I don't think our CI jobs enable the
--timeoutflag, so I only ran the testing locally viaBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.