#include <AEDetector.h>
Definition at line 330 of file AEDetector.h.
◆ NullptrDerefDetector()
| SVF::NullptrDerefDetector::NullptrDerefDetector |
( |
| ) |
|
|
inline |
Definition at line 334 of file AEDetector.h.
335 {
337 }
@ 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 376 of file AEDetector.h.
377 {
381
383 {
384 return;
385 }
387
388
390 {
391 return;
392 }
393 else
394 {
396 }
399 }
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 695 of file AEDetector.cpp.
696{
699
701
702 if (!
AbsVal.isAddr())
return true;
704 {
705
707 return false;
708
710 return false;
711
712 else if (
as.isFreedMem(
addr))
713 return false;
714 }
715
716
717 return true;
718}
static bool isNullMem(u32_t addr)
static bool isBlackHoleObjAddr(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 542 of file AEDetector.cpp.
543{
544 if (SVFUtil::isa<CallICFGNode>(node))
545 {
546
547
550 {
552 }
553 }
554 else
555 {
556 for (
const auto&
stmt: node->getSVFStmts())
557 {
559 {
560
561
564 {
567 }
568 }
569 else if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(
stmt))
570 {
571
572
575 {
578 }
579 }
580 }
581 }
582}
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 636 of file AEDetector.cpp.
637{
639
640
642 for (
const std::string &
annotation:
ExtAPI::getExtAPI()->getExtFuncAnnotations(call->getCalledFunction()))
643 {
644 if (
annotation.find(
"MEMCPY") != std::string::npos)
645 {
647 {
648
651 }
652 else
653 {
654
659 }
660 }
661 else if (
annotation.find(
"MEMSET") != std::string::npos)
662 {
663
665 }
666 else if (
annotation.find(
"STRCPY") != std::string::npos)
667 {
668
671 }
672 else if (
annotation.find(
"STRCAT") != std::string::npos)
673 {
674
675
678 }
679 }
680
682 {
684 continue;
687 {
690 }
691 }
692}
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 585 of file AEDetector.cpp.
586{
587 std::string funcName =
callNode->getCalledFunction()->getName();
588 if (funcName == "UNSAFE_LOAD")
589 {
590
593 return;
595
597
600 {
602 <<
" — " <<
callNode->toString() <<
"\n";
603 return;
604 }
605 else
606 {
608 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
610 }
611 }
612 else if (funcName == "SAFE_LOAD")
613 {
614
616 if (
callNode->arg_size() < 1)
return;
619
622 {
624 <<
" — " <<
callNode->toString() <<
"\n";
625 return;
626 }
627 else
628 {
630 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
632 }
633 }
634}
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 431 of file AEDetector.h.
432 {
433 return !
v.isAddr() && !
v.isInterval();
434 }
◆ 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 364 of file AEDetector.h.
365 {
366
367 bool is =
v.getAddrs().isBottom() &&
v.getInterval().isBottom();
369 }
◆ reportBug()
| void SVF::NullptrDerefDetector::reportBug |
( |
| ) |
|
|
inlinevirtual |
Reports all detected nullptr dereference bugs.
Implements SVF::AEDetector.
Definition at line 404 of file AEDetector.h.
405 {
407 {
408 std::cerr <<
"###################### Nullptr Dereference (" + std::to_string(
nodeToBugInfo.size())
409 + " found)######################\n";
410 std::cerr << "---------------------------------------------\n";
412 {
413 std::cerr <<
it.second <<
"\n---------------------------------------------\n";
414 }
415 }
416 }
◆ AbstractInterpretation
◆ bugLoc
| Set<std::string> SVF::NullptrDerefDetector::bugLoc |
|
private |
Set of locations where bugs have been reported.
Definition at line 439 of file AEDetector.h.
◆ nodeToBugInfo
◆ recoder
Recorder for abstract execution bugs.
Definition at line 440 of file AEDetector.h.
The documentation for this class was generated from the following files: