Github user jeking3 commented on a diff in the pull request:
https://github.com/apache/thrift/pull/1128#discussion_r95216695
--- Diff: lib/cpp/src/thrift/transport/THeaderTransport.cpp ---
@@ -375,7 +383,12 @@ void THeaderTransport::resetProtocol() {
}
uint32_t THeaderTransport::getWriteBytes() {
- return wBase_ - wBuf_.get();
+ ptrdiff_t wb = wBase_ - wBuf_.get();
+ if (wb > std::numeric_limits<uint32_t>().max()) {
+ throw TTransportException(TTransportException::CORRUPTED_DATA,
+ "write size is unreasonable");
+ }
--- End diff --
Unfortunately using a template like this caused build warnings to occur
when the inputs are not the same signed-ness. I think these bounds checks need
to be done with eyes wide open, and need to be specific in each case in order
to avoid compiler warnings.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---