Static Value-Flow Analysis
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
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, s64_t allocLowerBound, s64_t allocUpperBound, s64_t accessLowerBound, s64_t accessUpperBound)
 
cJSONgetBugDescription () const
 
void printBugToTerminal () const
 
- Public Member Functions inherited from SVF::GenericBug
 GenericBug (BugType bugType, const EventStack &bugEventStack)
 note: should be initialized with a bugEventStack More...
 
virtual ~GenericBug ()=default
 
BugType getBugType () const
 returns bug type More...
 
const std::string getLoc () const
 returns bug location as json format string More...
 
const std::string getFuncName () const
 return bug source function name More...
 
const EventStackgetEventStack () const
 

Static Public Member Functions

static bool classof (const GenericBug *bug)
 ClassOf. More...
 

Protected Attributes

s64_t allocLowerBound
 
s64_t allocUpperBound
 
s64_t accessLowerBound
 
s64_t 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< SVFBugEventEventStack
 
- Static Public Attributes inherited from SVF::GenericBug
static const std::map< GenericBug::BugType, std::stringBugType2Str
 

Detailed Description

Definition at line 121 of file SVFBugReport.h.

Constructor & Destructor Documentation

◆ BufferOverflowBug()

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

Definition at line 127 of file SVFBugReport.h.

129  :
GenericBug(BugType bugType, const EventStack &bugEventStack)
note: should be initialized with a bugEventStack
Definition: SVFBugReport.h:95

Member Function Documentation

◆ classof()

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

ClassOf.

Definition at line 138 of file SVFBugReport.h.

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

◆ getBugDescription()

cJSON * BufferOverflowBug::getBugDescription ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 63 of file SVFBugReport.cpp.

64 {
65  cJSON *bugDescription = cJSON_CreateObject();
66  cJSON *allocLB = cJSON_CreateNumber(allocLowerBound);
67  cJSON *allocUB = cJSON_CreateNumber(allocUpperBound);
68  cJSON *accessLB = cJSON_CreateNumber(accessLowerBound);
69  cJSON *accessUB = cJSON_CreateNumber(accessUpperBound);
70 
71  cJSON_AddItemToObject(bugDescription, "AllocLowerBound", allocLB);
72  cJSON_AddItemToObject(bugDescription, "AllocUpperBound", allocUB);
73  cJSON_AddItemToObject(bugDescription, "AccessLowerBound", accessLB);
74  cJSON_AddItemToObject(bugDescription, "AccessUpperBound", accessUB);
75 
76  return bugDescription;
77 }
Definition: cJSON.h:104

◆ printBugToTerminal()

void BufferOverflowBug::printBugToTerminal ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 79 of file SVFBugReport.cpp.

80 {
81  stringstream bugInfo;
83  {
84  SVFUtil::errs() << SVFUtil::bugMsg1("\t Full Overflow :") << " accessing at : ("
85  << GenericBug::getLoc() << ")\n";
86 
87  }
88  else
89  {
90  SVFUtil::errs() << SVFUtil::bugMsg1("\t Partial Overflow :") << " accessing at : ("
91  << GenericBug::getLoc() << ")\n";
92  }
93  bugInfo << "\t\t allocate size : [" << allocLowerBound << ", " << allocUpperBound << "], ";
94  bugInfo << "access size : [" << accessLowerBound << ", " << accessUpperBound << "]\n";
95  SVFUtil::errs() << "\t\t Info : \n" << bugInfo.str();
96  SVFUtil::errs() << "\t\t Events : \n";
97 
98  for(auto event : bugEventStack)
99  {
100  switch(event.getEventType())
101  {
103  {
104  SVFUtil::errs() << "\t\t callsite at : ( " << event.getEventLoc() << " )\n";
105  break;
106  }
107  default:
108  {
109  // TODO: implement more events when needed
110  break;
111  }
112  }
113  }
114 }
static bool classof(const GenericBug *bug)
ClassOf.
Definition: SVFBugReport.h:154
const std::string getLoc() const
returns bug location as json format string
const EventStack bugEventStack
Definition: SVFBugReport.h:91
std::string bugMsg1(const std::string &msg)
Definition: SVFUtil.cpp:81
std::ostream & errs()
Overwrite llvm::errs()
Definition: SVFUtil.h:56

Member Data Documentation

◆ accessLowerBound

s64_t SVF::BufferOverflowBug::accessLowerBound
protected

Definition at line 124 of file SVFBugReport.h.

◆ accessUpperBound

s64_t SVF::BufferOverflowBug::accessUpperBound
protected

Definition at line 124 of file SVFBugReport.h.

◆ allocLowerBound

s64_t SVF::BufferOverflowBug::allocLowerBound
protected

Definition at line 124 of file SVFBugReport.h.

◆ allocUpperBound

s64_t SVF::BufferOverflowBug::allocUpperBound
protected

Definition at line 124 of file SVFBugReport.h.


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