MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / SafeAdd

Function SafeAdd

Libraries/unrar/arcread.cpp:131–134  ·  view source on GitHub ↗

Return f in case of signed integer overflow or negative parameters or v1+v2 otherwise. We use it for file offsets, which are signed for compatibility with off_t in POSIX file functions and third party code. Signed integer overflow is the undefined behavior according to C++ standard and it causes fuzzers to complain.

Source from the content-addressed store, hash-verified

129// Signed integer overflow is the undefined behavior according to
130// C++ standard and it causes fuzzers to complain.
131inline int64 SafeAdd(int64 v1,int64 v2,int64 f)
132{
133 return v1>=0 && v2>=0 && v1<=MAX_INT64-v2 ? v1+v2 : f;
134}
135
136
137size_t Archive::ReadHeader15()

Callers 2

ReadHeader15Method · 0.85
ReadHeader50Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected