Static Value-Flow Analysis
FileChecker.cpp
Go to the documentation of this file.
1 //===- FileChecker.cpp -- Checking incorrect file-open close errors-----------//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-> <Yulei Sui>
6 //
7 
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
17 
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //===----------------------------------------------------------------------===//
22 
23 /*
24  * FileChecker.cpp
25  *
26  * Created on: Apr 24, 2014
27  * Author: Yulei Sui
28  */
29 
30 #include "SABER/FileChecker.h"
31 
32 using namespace SVF;
33 using namespace SVFUtil;
34 
35 
37 {
38 
39  if(isAllPathReachable() == false && isSomePathReachable() == false)
40  {
41  // full leakage
42  GenericBug::EventStack eventStack = { SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())) };
43  report.addSaberBug(GenericBug::FILENEVERCLOSE, eventStack);
44  }
45  else if (isAllPathReachable() == false && isSomePathReachable() == true)
46  {
47  GenericBug::EventStack eventStack;
48  slice->evalFinalCond2Event(eventStack);
49  eventStack.push_back(
50  SVFBugEvent(SVFBugEvent::SourceInst, getSrcCSID(slice->getSource())));
51  report.addSaberBug(GenericBug::FILEPARTIALCLOSE, eventStack);
52  }
53 }
void reportBug(ProgSlice *slice)
Report file/close bugs.
Definition: FileChecker.cpp:36
std::vector< SVFBugEvent > EventStack
Definition: SVFBugReport.h:83
void evalFinalCond2Event(GenericBug::EventStack &eventStack) const
Add final condition to eventStack.
Definition: ProgSlice.cpp:196
const SVFGNode * getSource() const
root and sink operations
Definition: ProgSlice.h:123
for isBitcode
Definition: BasicTypes.h:68