202 assert(
false &&
"GepObjVar not found in gepObjOffsetFromBase");
233 eventStack.push_back(sourceInstEvent);
235 if (eventStack.empty())
240 std::string loc = eventStack.back().getEventLoc();
267 std::cerr <<
"######################Buffer Overflow (" + std::to_string(
nodeToBugInfo.size())
268 +
" found)######################\n";
269 std::cerr <<
"---------------------------------------------\n";
272 std::cerr << it.second <<
"\n---------------------------------------------\n";
297 const ICFGNode* node, BufferOverflowInfo* info =
nullptr);
371 eventStack.push_back(sourceInstEvent);
373 if (eventStack.empty())
377 std::string loc = eventStack.back().getEventLoc();
400 std::cerr <<
"###################### Nullptr Dereference (" + std::to_string(
nodeToBugInfo.size())
401 +
" found)######################\n";
402 std::cerr <<
"---------------------------------------------\n";
405 std::cerr << it.second <<
"\n---------------------------------------------\n";
static bool classof(const AEDetector *detector)
Check if the detector is of the UNKNOWN kind.
DetectorKind
Enumerates the types of detectors available.
@ NULL_DEREF
Detector for nullptr dereference issues.
@ UNKNOWN
Default type if the kind is not specified.
@ BUF_OVERFLOW
Detector for buffer overflow issues.
virtual void handleStubFunctions(const CallICFGNode *call)=0
Pure virtual function for handling stub external API calls. (e.g. UNSAFE_BUFACCESS).
DetectorKind kind
The kind of the detector.
virtual void reportBug()=0
Pure virtual function to report detected bugs.
AEDetector()
Constructor initializes the detector kind to UNKNOWN.
virtual ~AEDetector()=default
Virtual destructor for safe polymorphic use.
virtual void detect(const ICFGNode *node)=0
Pure virtual function for detecting issues within a node.
DetectorKind getKind() const
Get the kind of the detector.
IntervalValue & getInterval()
AddressValue & getAddrs()
bool detectStrcat(const CallICFGNode *call, BufferOverflowInfo &info)
Detects buffer overflow in 'strcat' function calls.
void addToGepObjOffsetFromBase(const GepObjVar *obj, const IntervalValue &offset)
Adds an offset to a GEP object.
void detect(const ICFGNode *) override
Detect buffer overflow issues within a node.
void reportBug() override
Reports all detected buffer overflow bugs.
~BufOverflowDetector()=default
Destructor.
Map< const GepObjVar *, IntervalValue > gepObjOffsetFromBase
Maps GEP objects to their offsets from the base.
Map< std::string, std::vector< std::pair< u32_t, u32_t > > > extAPIBufOverflowCheckRules
Rules for checking buffer overflows in external APIs.
SVFBugReport recoder
Recorder for abstract execution bugs.
IntervalValue getAccessOffset(NodeID objId, const GepStmt *gep)
Retrieves the access offset for a given object and GEP statement.
void updateGepObjOffsetFromBase(const ICFGNode *node, AddressValue gepAddrs, AddressValue objAddrs, IntervalValue offset)
Updates the offset of a GEP object from its base.
void detectExtAPI(const CallICFGNode *call)
Handles external API calls related to buffer overflow detection.
void addBugToReporter(const ICFGNode *node, const SVFStmt *stmt=nullptr)
Reports a bug, generating its text only for a new location.
BufOverflowDetector()
Constructor initializes the detector kind to BUF_OVERFLOW and sets up external API buffer overflow ru...
Set< std::string > bugLoc
Set of locations where bugs have been reported.
void addBugToReporter(const ICFGNode *node, const BufferOverflowInfo &info, const SVFStmt *stmt=nullptr)
Report an OOB alarm with the buffer size and offset from its check.
IntervalValue getGepObjOffsetFromBase(const GepObjVar *obj) const
Retrieves the offset of a GEP object from its base.
static bool classof(const AEDetector *detector)
Check if the detector is of the BUF_OVERFLOW kind.
bool canSafelyAccessMemory(const ValVar *value, const IntervalValue &len, const ICFGNode *node, BufferOverflowInfo *info=nullptr)
Checks if memory can be safely accessed.
friend class AbstractInterpretation
void handleStubFunctions(const CallICFGNode *) override
Handles external API calls related to buffer overflow detection.
Map< const ICFGNode *, std::string > nodeToBugInfo
Maps ICFG nodes to bug information.
bool hasGepObjOffsetFromBase(const GepObjVar *obj) const
Checks if a GEP object has an associated offset.
void initExtAPIBufOverflowCheckRules()
Initializes external API buffer overflow check rules.
bool detectStrcpy(const CallICFGNode *call, BufferOverflowInfo &info)
Detects buffer overflow in 'strcpy' function calls.
std::vector< SVFBugEvent > EventStack
virtual const std::string toString() const
const BoundedInt & ub() const
Return the upper bound.
const BoundedInt & lb() const
Return the lower bound.
bool canSafelyDerefPtr(const ValVar *ptr, const ICFGNode *node)
Set< std::string > bugLoc
Set of locations where bugs have been reported.
bool isNull(AbstractValue v)
Check if an Abstract Value is NULL (or uninitialized).
bool isUninit(AbstractValue v)
Checks if an Abstract Value is uninitialized.
void handleStubFunctions(const CallICFGNode *call) override
Handles external API calls related to nullptr dereferences.
void detect(const ICFGNode *node) override
Detects nullptr dereferences issues within a node.
static bool classof(const AEDetector *detector)
friend class AbstractInterpretation
void reportBug() override
Reports all detected nullptr dereference bugs.
void addBugToReporter(const ICFGNode *node, const SVFStmt *stmt=nullptr)
Reports a bug, generating its text only for a new location.
void detectExtAPI(const CallICFGNode *call)
Handle external API calls related to nullptr dereferences.
SVFBugReport recoder
Recorder for abstract execution bugs.
Map< const ICFGNode *, std::string > nodeToBugInfo
Maps ICFG nodes to bug information.
~NullptrDerefDetector()=default
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
IntervalValue accessOffset