[
https://issues.apache.org/jira/browse/THRIFT-3978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16121982#comment-16121982
]
James E. King, III commented on THRIFT-3978:
--------------------------------------------
The following still need to be cleaned up before we can consider this story
complete:
{noformat}
jking@dvm:~/thrift/github/thrift$ find lib/cpp/src -type f -name '*.cpp' -exec
grep -l 'assert' {} \;
lib/cpp/src/thrift/VirtualProfiling.cpp
lib/cpp/src/thrift/windows/OverlappedSubmissionThread.cpp
lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
lib/cpp/src/thrift/server/TNonblockingServer.cpp
lib/cpp/src/thrift/protocol/TBase64Utils.cpp
lib/cpp/src/thrift/protocol/TDebugProtocol.cpp
lib/cpp/src/thrift/protocol/THeaderProtocol.cpp
lib/cpp/src/thrift/protocol/TJSONProtocol.cpp
lib/cpp/src/thrift/concurrency/Monitor.cpp
lib/cpp/src/thrift/concurrency/BoostMonitor.cpp
lib/cpp/src/thrift/concurrency/TimerManager.cpp
lib/cpp/src/thrift/concurrency/StdThreadFactory.cpp
lib/cpp/src/thrift/concurrency/BoostThreadFactory.cpp
lib/cpp/src/thrift/concurrency/Util.cpp
lib/cpp/src/thrift/concurrency/StdMutex.cpp
lib/cpp/src/thrift/concurrency/Mutex.cpp
lib/cpp/src/thrift/concurrency/StdMonitor.cpp
lib/cpp/src/thrift/concurrency/BoostMutex.cpp
lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp
lib/cpp/src/thrift/transport/TFileTransport.cpp
lib/cpp/src/thrift/transport/TBufferTransports.cpp
lib/cpp/src/thrift/transport/TSSLSocket.cpp
lib/cpp/src/thrift/transport/TZlibTransport.cpp
lib/cpp/src/thrift/transport/TPipe.cpp
lib/cpp/src/thrift/async/TEvhttpClientChannel.cpp
{noformat}
> Thrift C++ runtime uses assert to prevent overflows, checks sanity only in
> debug builds
> ---------------------------------------------------------------------------------------
>
> Key: THRIFT-3978
> URL: https://issues.apache.org/jira/browse/THRIFT-3978
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Library
> Affects Versions: 0.10.0
> Environment: All
> Reporter: James E. King, III
> Assignee: James E. King, III
> Labels: security
>
> Currently there is widespread use of assert in the thrift C++ runtime
> library. Some of the more disturbing cases are security related, for example
> checking header sizes. I recommend we eliminate assertions that are only
> checked in debug mode, and instead throw the appropriate exception, usually a
> TTransportException with CORRUPTED_DATA as the reason. If we're going to
> check for an overflow or a buffer overrun, we should do so in debug and
> release modes. Further, assertions are not easily tested whereas exceptions
> are.
> In THRIFT-3873 apache::thrift::transport::safe_numeric_cast was added, so I
> also suggest changing static_cast to safe_numeric_cast where appropriate
> throughout the transport code to catch any overflow errors.
> Another location where assert is used liberally is inside the posix Mutex
> implementation.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)