36class AbstractInterpretation;
37class AbstractStateManager;
224 assert(
false &&
"GepObjVar not found in gepObjOffsetFromBase");
279 std::cerr <<
"######################Buffer Overflow (" + std::to_string(
nodeToBugInfo.size())
280 +
" found)######################\n";
281 std::cerr <<
"---------------------------------------------\n";
284 std::cerr <<
it.second <<
"\n---------------------------------------------\n";
369 bool is =
v.getAddrs().isBottom() &&
v.getInterval().isBottom();
410 std::cerr <<
"###################### Nullptr Dereference (" + std::to_string(
nodeToBugInfo.size())
411 +
" found)######################\n";
412 std::cerr <<
"---------------------------------------------\n";
415 std::cerr <<
it.second <<
"\n---------------------------------------------\n";
435 return !
v.isAddr() && !
v.isInterval();
Base class for all detectors.
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.
Exception class for handling errors in Abstract Execution.
virtual const char * what() const
Provides the error message.
AEException(const std::string &message)
Constructor initializes the exception with a message.
std::string msg_
The error message.
AbstractInterpretation is same as Abstract Execution.
Detector for identifying buffer overflow issues.
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.
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.
bool canSafelyAccessMemory(const ValVar *value, const IntervalValue &len, const ICFGNode *node)
Checks if memory can be safely accessed.
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 detectStrcpy(const CallICFGNode *call)
Detects buffer overflow in 'strcpy' function calls.
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 detectStrcat(const CallICFGNode *call)
Detects buffer overflow in 'strcat' function calls.
void addBugToReporter(const AEException &e, const ICFGNode *node)
Adds a bug to the reporter based on an exception.
std::vector< SVFBugEvent > EventStack
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)
void addBugToReporter(const AEException &e, const ICFGNode *node)
Adds a bug to the reporter based on an exception.
void reportBug() override
Reports all detected nullptr dereference bugs.
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
void addAbsExecBug(GenericBug::BugType bugType, const GenericBug::EventStack &eventStack, s64_t allocLowerBound, s64_t allocUpperBound, s64_t accessLowerBound, s64_t accessUpperBound)
llvm::IRBuilder IRBuilder