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

#include <SVFBugReport.h>

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

Public Member Functions

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

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

Detailed Description

Definition at line 239 of file SVFBugReport.h.

Constructor & Destructor Documentation

◆ FilePartialCloseBug()

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

Definition at line 242 of file SVFBugReport.h.

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

Member Function Documentation

◆ classof()

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

ClassOf.

Definition at line 249 of file SVFBugReport.h.

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

◆ getBugDescription()

cJSON * FilePartialCloseBug::getBugDescription ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 230 of file SVFBugReport.cpp.

231{
232 cJSON *bugDescription = cJSON_CreateObject();
233
234 cJSON *pathInfo = cJSON_CreateArray();
235
236 auto lastBranchEventIt = bugEventStack.end() - 1;
237 for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
238 {
239 cJSON *newBranch = cJSON_CreateObject();
240 cJSON *branchLoc = cJSON_Parse((*eventIt).getEventLoc().c_str());
241 if(branchLoc == nullptr) branchLoc = cJSON_CreateObject();
242 cJSON *branchCondition = cJSON_CreateString((*eventIt).getEventDescription().c_str());
243
244 cJSON_AddItemToObject(newBranch, "BranchLoc", branchLoc);
245 cJSON_AddItemToObject(newBranch, "BranchCond", branchCondition);
246
247 cJSON_AddItemToArray(pathInfo, newBranch);
248 }
249 cJSON_AddItemToObject(bugDescription, "ConditionalFileClosePath", pathInfo);
250
251 return bugDescription;
252}
struct cJSON cJSON

◆ printBugToTerminal()

void FilePartialCloseBug::printBugToTerminal ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 254 of file SVFBugReport.cpp.

255{
256 SVFUtil::errs() << SVFUtil::bugMsg2("\t PartialFileClose :") << " file open location at : ("
257 << GenericBug::getLoc() << ")\n";
258
259 SVFUtil::errs() << "\t\t conditional file close path: \n";
260 auto lastBranchEventIt = bugEventStack.end() - 1;
261 for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
262 {
263 SVFUtil::errs() << "\t\t --> (" << (*eventIt).getEventLoc() << "|" << (*eventIt).getEventDescription() << ") \n";
264 }
265 SVFUtil::errs() << "\n";
266}
const std::string getLoc() const
returns bug location as json format string
std::ostream & errs()
Overwrite llvm::errs().
Definition SVFUtil.h:64
std::string bugMsg2(const std::string &msg)
Definition SVFUtil.cpp:108

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