-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: bitops_family crash fixed #4989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/server/bitops_family.cc
Outdated
if (last_byte_offset >= total_bytes) { | ||
return {}; | ||
} | ||
|
||
int32_t byte_index = GetByteIndex(offset); | ||
if (byte_index >= total_bytes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (last_byte_offset >= total_bytes) { | |
return {}; | |
} | |
int32_t byte_index = GetByteIndex(offset); | |
if (byte_index >= total_bytes) { | |
if (last_byte_offset >= total_bytes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sufficient. We check the expression above GetByteIndex(attr_.offset + attr_.encoding_bit_size - 1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kostasrim
This is not enough.
I updated the condition, please take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kostasrim
Please, take a look again.
src/server/bitops_family.cc
Outdated
int32_t lsb_byte_index = GetByteIndex(lsb); | ||
if (lsb_byte_index >= total_bytes) { | ||
return {}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to check again here. The above check is sufficient -- we can remove this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Small comment
src/server/bitops_family.cc
Outdated
@@ -728,17 +728,25 @@ ResultType Get::ApplyTo(Overflow ov, const string* bitfield) { | |||
const size_t offset = attr_.offset; | |||
auto last_byte_offset = GetByteIndex(attr_.offset + attr_.encoding_bit_size - 1); | |||
|
|||
if (GetByteIndex(offset) >= total_bytes && attr_.encoding_bit_size > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (GetByteIndex(offset) >= total_bytes && attr_.encoding_bit_size > 0) { | |
if (GetByteIndex(offset) >= total_bytes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because attr_.encoding_bit_size > 0
is always true
. (See how we parse the arguments for this command)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
fixes: #4988