-
Notifications
You must be signed in to change notification settings - Fork 385
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
thrift : fix list<bool> #382
Conversation
merge from master
if (!buffer->readI32(count)) | ||
return false; | ||
|
||
list->resize(count); |
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.
这里是否容易被OOM攻击
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.
这个要改的就多了。以后再说吧。
for (size_t i = 0; i < list->size(); ++i) | ||
{ | ||
bool ele; | ||
if (!val_desc->reader(buffer, &ele)) | ||
return false; | ||
(*list)[i] = ele; | ||
} |
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.
对于这个场景(由于要求使用C++ 11
标准),如果想避免特化class ThriftDescriptorImpl<std::vector<bool>, TDT_LIST, void, VALIMPL>
这个很长的类,并且对val_desc
的特化的代码更方便,可以将这部分内容实现为
using vector_value_ref = typename T::reference;
for (vector_value_ref ele : *list)
{
// do something with ele
}
并对val_desc
模板参数std::vector<bool>::reference
类型进行特化。注意,这个坏坏的std::vector<bool>::reference
看起来是引用,其实它是一个值类型。
srpc/src/thrift/rpc_thrift_idl.cc Lines 166 to 167 in 7712ed1
对于输入为LONG_MIN,这里有个有符号数上溢 |
#381