Skip to content

Conversation

@kevinAlbs
Copy link
Collaborator

Follow-up to #2156 to check for the case where inlen is UINT_MAX before adding one.

// `inlen` is a string length (excluding trailing NULL).
// Cyrus-SASL passes an `out` buffer of size `out_max + 1`. Assume `out_max` is the max to be safe.
if (inlen + 1 >= out_max) {
if (inlen == UINT_MAX || inlen + 1 >= out_max) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I recommend using mlib_add() here, since it is not sensitive to the types of its argument, while this relies on UINT_MAX always being the correct value to check.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Updated to use mlib_add().

Copy link
Contributor

@vector-of-bool vector-of-bool left a comment

Choose a reason for hiding this comment

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

LGTM with minor tweak

// `inlen` is a string length (excluding trailing NULL).
// Cyrus-SASL passes an `out` buffer of size `out_max + 1`. Assume `out_max` is the max to be safe.
if (inlen + 1 >= out_max) {
unsigned inlen_1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to init = 0 for MSVC quirks

@kevinAlbs kevinAlbs merged commit d9c26f4 into mongodb:master Oct 24, 2025
44 of 46 checks 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