#include <AEDetector.h>
Definition at line 326 of file AEDetector.h.
◆ NullptrDerefDetector()
SVF::NullptrDerefDetector::NullptrDerefDetector |
( |
| ) |
|
|
inline |
Definition at line 330 of file AEDetector.h.
331 {
333 }
@ NULL_DEREF
Detector for nullptr dereference issues.
DetectorKind kind
The kind of the detector.
◆ ~NullptrDerefDetector()
SVF::NullptrDerefDetector::~NullptrDerefDetector |
( |
| ) |
|
|
default |
◆ addBugToReporter()
Adds a bug to the reporter based on an exception.
- Parameters
-
e | The exception that was thrown. |
node | Pointer to the ICFG node where the bug was detected. |
Definition at line 372 of file AEDetector.h.
373 {
377
379 {
380 return;
381 }
383
384
386 {
387 return;
388 }
389 else
390 {
392 }
395 }
std::vector< SVFBugEvent > EventStack
Set< std::string > bugLoc
Set of locations where bugs have been reported.
SVFBugReport recoder
Recorder for abstract execution bugs.
Map< const ICFGNode *, std::string > nodeToBugInfo
Maps ICFG nodes to bug information.
void addAbsExecBug(GenericBug::BugType bugType, const GenericBug::EventStack &eventStack, s64_t allocLowerBound, s64_t allocUpperBound, s64_t accessLowerBound, s64_t accessUpperBound)
llvm::IRBuilder IRBuilder
◆ canSafelyDerefPtr()
Definition at line 678 of file AEDetector.cpp.
679{
682
684
685 if (!
AbsVal.isAddr())
return true;
687 {
688
690 return false;
691
693 return false;
694
695 else if (
as.isFreedMem(
addr))
696 return false;
697 }
698
699
700 return true;
701}
static bool isNullMem(u32_t addr)
static bool isInvalidMem(u32_t addr)
bool isUninit(AbstractValue v)
Checks if an Abstract Value is uninitialized.
◆ classof()
◆ detect()
Detects nullptr dereferences issues within a node.
- Parameters
-
as | Reference to the abstract state. |
node | Pointer to the ICFG node. |
Implements SVF::AEDetector.
Definition at line 525 of file AEDetector.cpp.
526{
527 if (SVFUtil::isa<CallICFGNode>(node))
528 {
529
530
533 {
535 }
536 }
537 else
538 {
539 for (
const auto&
stmt: node->getSVFStmts())
540 {
542 {
543
544
547 {
550 }
551 }
552 else if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(
stmt))
553 {
554
555
558 {
561 }
562 }
563 }
564 }
565}
Exception class for handling errors in Abstract Execution.
bool canSafelyDerefPtr(AbstractState &as, const SVFVar *ptr)
void addBugToReporter(const AEException &e, const ICFGNode *node)
Adds a bug to the reporter based on an exception.
void detectExtAPI(AbstractState &as, const CallICFGNode *call)
Handle external API calls related to nullptr dereferences.
bool isExtCall(const FunObjVar *fun)
◆ detectExtAPI()
Handle external API calls related to nullptr dereferences.
- Parameters
-
as | Reference to the abstract state. |
call | Pointer to the call ICFG node. |
Definition at line 619 of file AEDetector.cpp.
620{
622
623
625 for (
const std::string &
annotation:
ExtAPI::getExtAPI()->getExtFuncAnnotations(call->getCalledFunction()))
626 {
627 if (
annotation.find(
"MEMCPY") != std::string::npos)
628 {
630 {
631
634 }
635 else
636 {
637
642 }
643 }
644 else if (
annotation.find(
"MEMSET") != std::string::npos)
645 {
646
648 }
649 else if (
annotation.find(
"STRCPY") != std::string::npos)
650 {
651
654 }
655 else if (
annotation.find(
"STRCAT") != std::string::npos)
656 {
657
658
661 }
662 }
663
665 {
667 continue;
670 {
673 }
674 }
675}
const std::string toString() const override
const ValVar * getArgument(u32_t ArgNo) const
Parameter operations.
const FunObjVar * getCalledFunction() const
◆ handleStubFunctions()
Handles external API calls related to nullptr dereferences.
- Parameters
-
call | Pointer to the call ICFG node. |
Implements SVF::AEDetector.
Definition at line 568 of file AEDetector.cpp.
569{
570 std::string funcName =
callNode->getCalledFunction()->getName();
571 if (funcName == "UNSAFE_LOAD")
572 {
573
576 return;
578
580
583 {
585 <<
" — " <<
callNode->toString() <<
"\n";
586 return;
587 }
588 else
589 {
591 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
593 }
594 }
595 else if (funcName == "SAFE_LOAD")
596 {
597
599 if (
callNode->arg_size() < 1)
return;
602
605 {
607 <<
" — " <<
callNode->toString() <<
"\n";
608 return;
609 }
610 else
611 {
613 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
615 }
616 }
617}
static AbstractInterpretation & getAEInstance()
AbstractState & getAbsStateFromTrace(const ICFGNode *node)
Retrieves the abstract state from the trace for a given ICFG node.
Set< const CallICFGNode * > checkpoints
NodeID getId() const
Get ID.
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
std::ostream & outs()
Overwrite llvm::outs()
◆ isNull()
Check if an Abstract Value is NULL (or uninitialized).
- Parameters
-
v | An Abstract Value of loaded from an address in an Abstract State. |
Definition at line 427 of file AEDetector.h.
428 {
429 return !
v.isAddr() && !
v.isInterval();
430 }
◆ isUninit()
Checks if an Abstract Value is uninitialized.
- Parameters
-
v | The Abstract Value to check. |
- Returns
- True if the value is uninitialized, false otherwise.
Definition at line 360 of file AEDetector.h.
361 {
362
363 bool is =
v.getAddrs().isBottom() &&
v.getInterval().isBottom();
365 }
◆ reportBug()
void SVF::NullptrDerefDetector::reportBug |
( |
| ) |
|
|
inlinevirtual |
Reports all detected nullptr dereference bugs.
Implements SVF::AEDetector.
Definition at line 400 of file AEDetector.h.
401 {
403 {
404 std::cerr <<
"###################### Nullptr Dereference (" + std::to_string(
nodeToBugInfo.size())
405 + " found)######################\n";
406 std::cerr << "---------------------------------------------\n";
408 {
409 std::cerr <<
it.second <<
"\n---------------------------------------------\n";
410 }
411 }
412 }
◆ AbstractInterpretation
◆ bugLoc
Set<std::string> SVF::NullptrDerefDetector::bugLoc |
|
private |
Set of locations where bugs have been reported.
Definition at line 435 of file AEDetector.h.
◆ nodeToBugInfo
◆ recoder
Recorder for abstract execution bugs.
Definition at line 436 of file AEDetector.h.
The documentation for this class was generated from the following files: