[
https://issues.apache.org/jira/browse/THRIFT-3873?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15812484#comment-15812484
]
ASF GitHub Bot commented on THRIFT-3873:
----------------------------------------
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.
> Fix various compiler warnings when using VS2010
> -----------------------------------------------
>
> Key: THRIFT-3873
> URL: https://issues.apache.org/jira/browse/THRIFT-3873
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Library
> Affects Versions: 0.10.0
> Environment: VS2010, Windows
> Reporter: James E. King, III
> Assignee: James E. King, III
> Priority: Minor
>
> While verifying a defect I had to build the windows thrift C++ library and
> found a number of compiler warnings that needed to be cleaned up. As part of
> cleaning these up, I found that additional compilers were also posting
> warnings.
> Acceptance Criteria:
> # I can build successfully with Visual Studio 2010 targeting x86 debug mode
> with /WX (warnings are errors).
> # I can build successfully with Visual Studio 2010 targeting x86 release mode
> with /WX (warnings are errors).
> # I can build successfully with Visual Studio 2010 targeting x64 debug mode
> with /WX (warnings are errors).
> # I can build successfully with Visual Studio 2010 targeting x64 release mode
> with /WX (warnings are errors).
> # I can build successfully with Visual Studio 2015 targeting x86 debug mode
> with /WX (warnings are errors).
> # I can build successfully with Visual Studio 2015 targeting x86 release mode
> with /WX (warnings are errors).
> # I can build successfully with Visual Studio 2015 targeting x64 debug mode
> with /WX (warnings are errors).
> # I can build successfully with Visual Studio 2015 targeting x64 release mode
> with /WX (warnings are errors).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)