Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVF::BufferOverflowBug Class Reference

#include <SVFBugReport.h>

Inheritance diagram for SVF::BufferOverflowBug:
SVF::GenericBug SVF::FullBufferOverflowBug SVF::PartialBufferOverflowBug

Public Member Functions

 BufferOverflowBug (GenericBug::BugType bugType, const EventStack &eventStack, BoundedInt allocLowerBound, BoundedInt allocUpperBound, BoundedInt accessLowerBound, BoundedInt accessUpperBound)
cJSON * getBugDescription () const
void printBugToTerminal () const
Public Member Functions inherited from SVF::GenericBug
 GenericBug (BugType bugType, const EventStack &bugEventStack)
 note: should be initialized with a bugEventStack
virtual ~GenericBug ()=default
BugType getBugType () const
 returns bug type
const std::string getLoc () const
 returns bug location as json format string
const std::string getFuncName () const
 return bug source function name
const EventStack & getEventStack () const

Static Public Member Functions

static bool classof (const GenericBug *bug)
 ClassOf.

Protected Attributes

BoundedInt allocLowerBound
BoundedInt allocUpperBound
BoundedInt accessLowerBound
BoundedInt accessUpperBound
Protected Attributes inherited from SVF::GenericBug
BugType bugType
const EventStack bugEventStack

Additional Inherited Members

Public Types inherited from SVF::GenericBug
enum  BugType {
  FULLBUFOVERFLOW , PARTIALBUFOVERFLOW , NEVERFREE , PARTIALLEAK ,
  DOUBLEFREE , FILENEVERCLOSE , FILEPARTIALCLOSE , FULLNULLPTRDEREFERENCE ,
  PARTIALNULLPTRDEREFERENCE
}
typedef std::vector< SVFBugEvent > EventStack
Static Public Attributes inherited from SVF::GenericBug
static const OrderedMap< GenericBug::BugType, std::string > BugType2Str

Detailed Description

Definition at line 120 of file SVFBugReport.h.

Constructor & Destructor Documentation

◆ BufferOverflowBug()

SVF::BufferOverflowBug::BufferOverflowBug ( GenericBug::BugType bugType,
const EventStack & eventStack,
BoundedInt allocLowerBound,
BoundedInt allocUpperBound,
BoundedInt accessLowerBound,
BoundedInt accessUpperBound )
inline

Definition at line 126 of file SVFBugReport.h.

128 :
GenericBug(BugType bugType, const EventStack &bugEventStack)
note: should be initialized with a bugEventStack

Member Function Documentation

◆ classof()

bool SVF::BufferOverflowBug::classof ( const GenericBug * bug)
inlinestatic

ClassOf.

Definition at line 137 of file SVFBugReport.h.

138 {
139 return bug->getBugType() == GenericBug::PARTIALBUFOVERFLOW || bug->getBugType() == GenericBug::FULLBUFOVERFLOW;
140 }

◆ getBugDescription()

cJSON * BufferOverflowBug::getBugDescription ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 67 of file SVFBugReport.cpp.

68{
69 const auto endpoint = [](const BoundedInt& value)
70 {
71 if (value.is_infinity())
72 return cJSON_CreateString(value.is_plus_infinity() ? "+oo" : "-oo");
73 return cJSON_CreateNumber(value.getNumeral());
74 };
75 cJSON *bugDescription = cJSON_CreateObject();
76 cJSON *allocLB = endpoint(allocLowerBound);
77 cJSON *allocUB = endpoint(allocUpperBound);
78 cJSON *accessLB = endpoint(accessLowerBound);
79 cJSON *accessUB = endpoint(accessUpperBound);
80
81 cJSON_AddItemToObject(bugDescription, "AllocLowerBound", allocLB);
82 cJSON_AddItemToObject(bugDescription, "AllocUpperBound", allocUB);
83 cJSON_AddItemToObject(bugDescription, "AccessLowerBound", accessLB);
84 cJSON_AddItemToObject(bugDescription, "AccessUpperBound", accessUB);
85
86 return bugDescription;
87}
struct cJSON cJSON

◆ printBugToTerminal()

void BufferOverflowBug::printBugToTerminal ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 89 of file SVFBugReport.cpp.

90{
91 const auto endpoint = [](const BoundedInt& value) -> std::string
92 {
93 if (value.is_infinity()) return value.is_plus_infinity() ? "+oo" : "-oo";
94 return std::to_string(value.getNumeral());
95 };
96 stringstream bugInfo;
98 {
99 SVFUtil::errs() << SVFUtil::bugMsg1("\t Full Overflow :") << " accessing at : ("
100 << GenericBug::getLoc() << ")\n";
101
102 }
103 else
104 {
105 SVFUtil::errs() << SVFUtil::bugMsg1("\t Partial Overflow :") << " accessing at : ("
106 << GenericBug::getLoc() << ")\n";
107 }
108 bugInfo << "\t\t allocate size : [" << endpoint(allocLowerBound) << ", " << endpoint(allocUpperBound) << "], ";
109 bugInfo << "access size : [" << endpoint(accessLowerBound) << ", " << endpoint(accessUpperBound) << "]\n";
110 SVFUtil::errs() << "\t\t Info : \n" << bugInfo.str();
111 SVFUtil::errs() << "\t\t Events : \n";
112
113 for(auto event : bugEventStack)
114 {
115 switch(event.getEventType())
116 {
118 {
119 SVFUtil::errs() << "\t\t callsite at : ( " << event.getEventLoc() << " )\n";
120 break;
121 }
122 default:
123 {
124 // TODO: implement more events when needed
125 break;
126 }
127 }
128 }
129}
static bool classof(const GenericBug *bug)
ClassOf.
const std::string getLoc() const
returns bug location as json format string
const EventStack bugEventStack
std::string bugMsg1(const std::string &msg)
Definition SVFUtil.cpp:103
std::ostream & errs()
Overwrite llvm::errs().
Definition SVFUtil.h:64

Member Data Documentation

◆ accessLowerBound

BoundedInt SVF::BufferOverflowBug::accessLowerBound
protected

Definition at line 123 of file SVFBugReport.h.

◆ accessUpperBound

BoundedInt SVF::BufferOverflowBug::accessUpperBound
protected

Definition at line 123 of file SVFBugReport.h.

◆ allocLowerBound

BoundedInt SVF::BufferOverflowBug::allocLowerBound
protected

Definition at line 123 of file SVFBugReport.h.

◆ allocUpperBound

BoundedInt SVF::BufferOverflowBug::allocUpperBound
protected

Definition at line 123 of file SVFBugReport.h.


The documentation for this class was generated from the following files: