Static Value-Flow Analysis
Public Member Functions | Static Public Member Functions | List of all members
SVF::FilePartialCloseBug Class Reference

#include <SVFBugReport.h>

Inheritance diagram for SVF::FilePartialCloseBug:
SVF::GenericBug

Public Member Functions

 FilePartialCloseBug (const EventStack &bugEventStack)
 
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...
 

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
 
- Protected Attributes inherited from SVF::GenericBug
BugType bugType
 
const EventStack bugEventStack
 

Detailed Description

Definition at line 240 of file SVFBugReport.h.

Constructor & Destructor Documentation

◆ FilePartialCloseBug()

SVF::FilePartialCloseBug::FilePartialCloseBug ( const EventStack bugEventStack)
inline

Definition at line 243 of file SVFBugReport.h.

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

Member Function Documentation

◆ classof()

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

ClassOf.

Definition at line 250 of file SVFBugReport.h.

251  {
252  return bug->getBugType() == GenericBug::FILEPARTIALCLOSE;
253  }

◆ getBugDescription()

cJSON * FilePartialCloseBug::getBugDescription ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 215 of file SVFBugReport.cpp.

216 {
217  cJSON *bugDescription = cJSON_CreateObject();
218 
219  cJSON *pathInfo = cJSON_CreateArray();
220 
221  auto lastBranchEventIt = bugEventStack.end() - 1;
222  for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
223  {
224  cJSON *newBranch = cJSON_CreateObject();
225  cJSON *branchLoc = cJSON_Parse((*eventIt).getEventLoc().c_str());
226  if(branchLoc == nullptr) branchLoc = cJSON_CreateObject();
227  cJSON *branchCondition = cJSON_CreateString((*eventIt).getEventDescription().c_str());
228 
229  cJSON_AddItemToObject(newBranch, "BranchLoc", branchLoc);
230  cJSON_AddItemToObject(newBranch, "BranchCond", branchCondition);
231 
232  cJSON_AddItemToArray(pathInfo, newBranch);
233  }
234  cJSON_AddItemToObject(bugDescription, "ConditionalFileClosePath", pathInfo);
235 
236  return bugDescription;
237 }
Definition: cJSON.h:104

◆ printBugToTerminal()

void FilePartialCloseBug::printBugToTerminal ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 239 of file SVFBugReport.cpp.

240 {
241  SVFUtil::errs() << SVFUtil::bugMsg2("\t PartialFileClose :") << " file open location at : ("
242  << GenericBug::getLoc() << ")\n";
243 
244  SVFUtil::errs() << "\t\t conditional file close path: \n";
245  auto lastBranchEventIt = bugEventStack.end() - 1;
246  for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
247  {
248  SVFUtil::errs() << "\t\t --> (" << (*eventIt).getEventLoc() << "|" << (*eventIt).getEventDescription() << ") \n";
249  }
250  SVFUtil::errs() << "\n";
251 }
const std::string getLoc() const
returns bug location as json format string
std::ostream & errs()
Overwrite llvm::errs()
Definition: SVFUtil.h:56
std::string bugMsg2(const std::string &msg)
Definition: SVFUtil.cpp:86

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