218 assert(
false &&
"GepObjVar not found in gepObjOffsetFromBase");
271 std::cerr <<
"######################Buffer Overflow (" + std::to_string(
nodeToBugInfo.size())
272 +
" found)######################\n";
273 std::cerr <<
"---------------------------------------------\n";
276 std::cerr <<
it.second <<
"\n---------------------------------------------\n";
363 bool is =
v.getAddrs().isBottom() &&
v.getInterval().isBottom();
404 std::cerr <<
"###################### Nullptr Dereference (" + std::to_string(
nodeToBugInfo.size())
405 +
" found)######################\n";
406 std::cerr <<
"---------------------------------------------\n";
409 std::cerr <<
it.second <<
"\n---------------------------------------------\n";
429 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.
DetectorKind getKind() const
Get the kind of the detector.
virtual void detect(AbstractState &as, const ICFGNode *node)=0
Pure virtual function for detecting issues within a node.
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.
IntervalValue getAccessOffset(AbstractState &as, NodeID objId, const GepStmt *gep)
Retrieves the access offset for a given object and GEP statement.
void addToGepObjOffsetFromBase(const GepObjVar *obj, const IntervalValue &offset)
Adds an offset to a GEP object.
~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.
void detect(AbstractState &as, const ICFGNode *)
Detect buffer overflow issues within a node.
bool detectStrcpy(AbstractState &as, const CallICFGNode *call)
Detects buffer overflow in 'strcpy' function calls.
SVFBugReport recoder
Recorder for abstract execution bugs.
BufOverflowDetector()
Constructor initializes the detector kind to BUF_OVERFLOW and sets up external API buffer overflow ru...
bool detectStrcat(AbstractState &as, const CallICFGNode *call)
Detects buffer overflow in 'strcat' function calls.
Set< std::string > bugLoc
Set of locations where bugs have been reported.
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.
void reportBug()
Reports all detected buffer overflow bugs.
Map< const ICFGNode *, std::string > nodeToBugInfo
Maps ICFG nodes to bug information.
void handleStubFunctions(const CallICFGNode *)
Handles external API calls related to buffer overflow detection.
bool hasGepObjOffsetFromBase(const GepObjVar *obj) const
Checks if a GEP object has an associated offset.
bool canSafelyAccessMemory(AbstractState &as, const SVFVar *value, const IntervalValue &len)
Checks if memory can be safely accessed.
void initExtAPIBufOverflowCheckRules()
Initializes external API buffer overflow check rules.
void detectExtAPI(AbstractState &as, const CallICFGNode *call)
Handles external API calls related to buffer overflow detection.
void updateGepObjOffsetFromBase(AbstractState &as, AddressValue gepAddrs, AddressValue objAddrs, IntervalValue offset)
Updates the offset of a GEP object from its base.
void addBugToReporter(const AEException &e, const ICFGNode *node)
Adds a bug to the reporter based on an exception.
std::vector< SVFBugEvent > EventStack
bool canSafelyDerefPtr(AbstractState &as, const SVFVar *ptr)
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 detect(AbstractState &as, const ICFGNode *node)
Detects nullptr dereferences issues within a node.
void reportBug()
Reports all detected nullptr dereference bugs.
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 handleStubFunctions(const CallICFGNode *call)
Handles external API calls related to nullptr dereferences.
SVFBugReport recoder
Recorder for abstract execution bugs.
void detectExtAPI(AbstractState &as, const CallICFGNode *call)
Handle external API calls related to nullptr dereferences.
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