#include <AEDetector.h>
Definition at line 332 of file AEDetector.h.
◆ NullptrDerefDetector()
| SVF::NullptrDerefDetector::NullptrDerefDetector |
( |
| ) |
|
|
inline |
Definition at line 336 of file AEDetector.h.
337 {
339 }
@ 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 378 of file AEDetector.h.
379 {
383
385 {
386 return;
387 }
389
390
392 {
393 return;
394 }
395 else
396 {
398 }
401 }
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 666 of file AEDetector.cpp.
667{
670
672
673 if (!
AbsVal.isAddr())
return true;
675 {
676
678 return false;
679
681 return false;
682
683 else if (
ae.getAbsState(node).isFreedMem(
addr))
684 return false;
685 }
686 return true;
687}
static AbstractInterpretation & getAEInstance()
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 514 of file AEDetector.cpp.
515{
516 if (SVFUtil::isa<CallICFGNode>(node))
517 {
518
519
522 {
524 }
525 }
526 else
527 {
528 for (
const auto&
stmt: node->getSVFStmts())
529 {
531 {
532
533
536 {
539 }
540 }
541 else if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(
stmt))
542 {
543
544
547 {
550 }
551 }
552 }
553 }
554}
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 607 of file AEDetector.cpp.
608{
610
611
613 for (
const std::string &
annotation:
ExtAPI::getExtAPI()->getExtFuncAnnotations(call->getCalledFunction()))
614 {
615 if (
annotation.find(
"MEMCPY") != std::string::npos)
616 {
618 {
619
622 }
623 else
624 {
625
630 }
631 }
632 else if (
annotation.find(
"MEMSET") != std::string::npos)
633 {
634
636 }
637 else if (
annotation.find(
"STRCPY") != std::string::npos)
638 {
639
642 }
643 else if (
annotation.find(
"STRCAT") != std::string::npos)
644 {
645
646
649 }
650 }
651
653 {
655 continue;
658 {
661 }
662 }
663}
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 557 of file AEDetector.cpp.
558{
559 std::string funcName =
callNode->getCalledFunction()->getName();
561 if (funcName == "UNSAFE_LOAD")
562 {
563
566 return;
567
569
572 {
574 <<
" — " <<
callNode->toString() <<
"\n";
575 return;
576 }
577 else
578 {
580 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
582 }
583 }
584 else if (funcName == "SAFE_LOAD")
585 {
586
588 if (
callNode->arg_size() < 1)
return;
590
593 {
595 <<
" — " <<
callNode->toString() <<
"\n";
596 return;
597 }
598 else
599 {
601 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
603 }
604 }
605}
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 433 of file AEDetector.h.
434 {
435 return !
v.isAddr() && !
v.isInterval();
436 }
◆ 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 366 of file AEDetector.h.
367 {
368
369 bool is =
v.getAddrs().isBottom() &&
v.getInterval().isBottom();
371 }
◆ reportBug()
| void SVF::NullptrDerefDetector::reportBug |
( |
| ) |
|
|
inlineoverridevirtual |
Reports all detected nullptr dereference bugs.
Implements SVF::AEDetector.
Definition at line 406 of file AEDetector.h.
407 {
409 {
410 std::cerr <<
"###################### Nullptr Dereference (" + std::to_string(
nodeToBugInfo.size())
411 + " found)######################\n";
412 std::cerr << "---------------------------------------------\n";
414 {
415 std::cerr <<
it.second <<
"\n---------------------------------------------\n";
416 }
417 }
418 }
◆ AbstractInterpretation
◆ bugLoc
| Set<std::string> SVF::NullptrDerefDetector::bugLoc |
|
private |
Set of locations where bugs have been reported.
Definition at line 441 of file AEDetector.h.
◆ nodeToBugInfo
◆ recoder
Recorder for abstract execution bugs.
Definition at line 442 of file AEDetector.h.
The documentation for this class was generated from the following files: