#include <AEDetector.h>
Definition at line 331 of file AEDetector.h.
◆ NullptrDerefDetector()
| SVF::NullptrDerefDetector::NullptrDerefDetector |
( |
| ) |
|
|
inline |
Definition at line 335 of file AEDetector.h.
336 {
338 }
@ 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 377 of file AEDetector.h.
378 {
382
384 {
385 return;
386 }
388
389
391 {
392 return;
393 }
394 else
395 {
397 }
400 }
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 669 of file AEDetector.cpp.
670{
674 if (!
AbsVal.isAddr())
return true;
676 {
677
679 return false;
680
682 return false;
683
684 else if (ae.getAbsState(node).isFreedMem(
addr))
685 return false;
686 }
687 return true;
688}
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 610 of file AEDetector.cpp.
611{
613
614
616 for (
const std::string &
annotation:
ExtAPI::getExtAPI()->getExtFuncAnnotations(call->getCalledFunction()))
617 {
618 if (
annotation.find(
"MEMCPY") != std::string::npos)
619 {
621 {
622
625 }
626 else
627 {
628
633 }
634 }
635 else if (
annotation.find(
"MEMSET") != std::string::npos)
636 {
637
639 }
640 else if (
annotation.find(
"STRCPY") != std::string::npos)
641 {
642
645 }
646 else if (
annotation.find(
"STRCAT") != std::string::npos)
647 {
648
649
652 }
653 }
654
656 {
658 continue;
661 {
664 }
665 }
666}
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
564 ae.getUtils()->checkpoints.erase(
callNode);
566 return;
567
569
573 << "\n";
575 {
577 <<
" — " <<
callNode->toString() <<
"\n";
578 return;
579 }
580 else
581 {
583 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
585 }
586 }
587 else if (funcName == "SAFE_LOAD")
588 {
589
590 ae.getUtils()->checkpoints.erase(
callNode);
591 if (
callNode->arg_size() < 1)
return;
593
596 {
598 <<
" — " <<
callNode->toString() <<
"\n";
599 return;
600 }
601 else
602 {
604 <<
" — Position: " <<
callNode->getSourceLoc() <<
"\n";
606 }
607 }
608}
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 432 of file AEDetector.h.
433 {
434 return !
v.isAddr() && !
v.isInterval();
435 }
◆ 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 365 of file AEDetector.h.
366 {
367
368 bool is =
v.getAddrs().isBottom() &&
v.getInterval().isBottom();
370 }
◆ reportBug()
| void SVF::NullptrDerefDetector::reportBug |
( |
| ) |
|
|
inlineoverridevirtual |
Reports all detected nullptr dereference bugs.
Implements SVF::AEDetector.
Definition at line 405 of file AEDetector.h.
406 {
408 {
409 std::cerr <<
"###################### Nullptr Dereference (" + std::to_string(
nodeToBugInfo.size())
410 + " found)######################\n";
411 std::cerr << "---------------------------------------------\n";
413 {
414 std::cerr <<
it.second <<
"\n---------------------------------------------\n";
415 }
416 }
417 }
◆ AbstractInterpretation
◆ bugLoc
| Set<std::string> SVF::NullptrDerefDetector::bugLoc |
|
private |
Set of locations where bugs have been reported.
Definition at line 440 of file AEDetector.h.
◆ nodeToBugInfo
◆ recoder
Recorder for abstract execution bugs.
Definition at line 441 of file AEDetector.h.
The documentation for this class was generated from the following files: