Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef index_t revision_t;
- ...
- void CCacheLogQuery::InternalLog (
- revision_t startRevision
- , revision_t endRevision
- , const CDictionaryBasedTempPath& startPath
- , int limit
- , const CLogOptions& options)
- {
- ...
- // we cannot receive logs for rev < 0
- if (endRevision < 0)
- endRevision = 0;
- ...
- }
- Negative values simply cannot appear here. The endRevision variable has the unsigned type and, therefore, endRevision is always >=0. The potential danger is this: if a negative value was cast to the unsigned type somewhere before, we will be handling a very big number. And there's no check for that.
- This suspicious code was found in TortoiseSVN project by PVS-Studio static code analyzer.
- Warning message is:
- V547 Expression 'endRevision < 0' is always false. Unsigned type value is never < 0. cachelogquery.cpp 999
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment