PYTHON-4305 Fix bson size check by ShaneHarvey · Pull Request #1564 · mongodb/mongo-python-driver
| /* code_w_scope length + code length + code + scope length */ | ||
| if (!code_size || max < code_size || max < 4 + 4 + code_size + 4) { | ||
| len = 4 + 4 + code_size + 4; | ||
| if (!code_size || max < code_size || max < len || len < code_size) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len < code_size catches when len overflows.
| /* code length + code + scope length + scope */ | ||
| if ((4 + code_size + 4 + scope_size) != c_w_s_size) { | ||
| len = 4 + 4 + code_size + scope_size; | ||
| if (scope_size < BSON_MIN_SIZE || len != c_w_s_size || len < scope_size) { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len < scope_size catches when len overflows.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
blink1073 pushed a commit that referenced this pull request
Mar 27, 2024(cherry picked from commit 372b5d6)
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