#include <AEDetector.h>
Definition at line 348 of file AEDetector.h.
◆ NullptrDerefDetector()
| SVF::NullptrDerefDetector::NullptrDerefDetector |
( |
| ) |
|
|
inline |
Definition at line 352 of file AEDetector.h.
353 {
355 }
@ 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 394 of file AEDetector.h.
395 {
399
401 {
402 return;
403 }
405
406
408 {
409 return;
410 }
411 else
412 {
414 }
417 }
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 691 of file AEDetector.cpp.
692{
696 if (!
AbsVal.isAddr())
return true;
698 {
699
701 ae.getAbsState(node).isFreedMem(
addr))
702 return false;
703 }
704 return true;
705}
static AbstractInterpretation & getAEInstance()
static bool isNullOrBlackHoleAddr(u32_t addr)
Whether addr has no concrete backing memory object.
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 536 of file AEDetector.cpp.
537{
538 if (SVFUtil::isa<CallICFGNode>(node))
539 {
540
541
544 {
546 }
547 }
548 else
549 {
550 for (const auto& stmt: node->getSVFStmts())
551 {
552 if (
const GepStmt*
gep = SVFUtil::dyn_cast<GepStmt>(stmt))
553 {
554
555
558 {
561 }
562 }
563 else if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(stmt))
564 {
565
566
569 {
572 }
573 }
574 }
575 }
576}
Exception class for handling errors in Abstract Execution.
bool canSafelyDerefPtr(const ValVar *ptr, const ICFGNode *node)
void addBugToReporter(const AEException &e, const ICFGNode *node)
Adds a bug to the reporter based on an exception.
void detectExtAPI(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 632 of file AEDetector.cpp.
633{
635
636
638 for (
const std::string &
annotation:
ExtAPI::getExtAPI()->getExtFuncAnnotations(call->getCalledFunction()))
639 {
640 if (
annotation.find(
"MEMCPY") != std::string::npos)
641 {
643 {
644
647 }
648 else
649 {
650
655 }
656 }
657 else if (
annotation.find(
"MEMSET") != std::string::npos)
658 {
659
661 }
662 else if (
annotation.find(
"STRCPY") != std::string::npos)
663 {
664
667 }
668 else if (
annotation.find(
"STRCAT") != std::string::npos)
669 {
670
671
674 }
675 }
676
678 {
680 continue;
683 {
686 }
687 }
688}
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 579 of file AEDetector.cpp.
580{
581 std::string funcName =
callNode->getCalledFunction()->getName();
583 if (funcName == "UNSAFE_LOAD")
584 {
585
586 ae.getUtils()->checkpoints.erase(
callNode);
588 return;
589
591
595 << "\n";
597 {
599 <<
" — " <<
callNode->toString() <<
"\n";
600 return;
601 }
602 else
603 {
605 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
607 }
608 }
609 else if (funcName == "SAFE_LOAD")
610 {
611
612 ae.getUtils()->checkpoints.erase(
callNode);
613 if (
callNode->arg_size() < 1)
return;
615
618 {
620 <<
" — " <<
callNode->toString() <<
"\n";
621 return;
622 }
623 else
624 {
626 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
628 }
629 }
630}
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 449 of file AEDetector.h.
450 {
451 return !
v.isAddr() && !
v.isInterval();
452 }
◆ 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 382 of file AEDetector.h.
383 {
384
385 bool is =
v.getAddrs().isBottom() &&
v.getInterval().isBottom();
387 }
◆ reportBug()
| void SVF::NullptrDerefDetector::reportBug |
( |
| ) |
|
|
inlineoverridevirtual |
Reports all detected nullptr dereference bugs.
Implements SVF::AEDetector.
Definition at line 422 of file AEDetector.h.
423 {
425 {
426 std::cerr <<
"###################### Nullptr Dereference (" + std::to_string(
nodeToBugInfo.size())
427 + " found)######################\n";
428 std::cerr << "---------------------------------------------\n";
430 {
431 std::cerr << it.second << "\n---------------------------------------------\n";
432 }
433 }
434 }
◆ AbstractInterpretation
◆ bugLoc
| Set<std::string> SVF::NullptrDerefDetector::bugLoc |
|
private |
Set of locations where bugs have been reported.
Definition at line 457 of file AEDetector.h.
◆ nodeToBugInfo
◆ recoder
Recorder for abstract execution bugs.
Definition at line 458 of file AEDetector.h.
The documentation for this class was generated from the following files: