-
Notifications
You must be signed in to change notification settings - Fork 28
Assignment 3
$tree Assignment-3
├── Assignment-3-Helper.cpp
├── Assignment-3.cpp
├── Assignment-3.h
├── CMakeLists.txt
└── Tests
├── CMakeLists.txt
├── ae
│ ├── test1.c
│ ├── test1.ll
│ ├── test2.c
│ ├── test2.ll
│ ├── test3.c
│ ├── test3.ll
│ ├── test4.c
│ ├── test4.ll
│ ├── test5.c
│ ├── test5.ll
│ ├── test6.c
│ └── test6.ll
├── buf
│ ├── test1.c
│ ├── test1.ll
│ ├── test2.c
│ └── test2.ll
└── test-ae.cpp
* Before coding, please type cd $HOME/Software-Security-Analysis
and git pull
in your terminal to make sure you always have the latest version of the code template before each assignment.
Make sure to switch your program to assign-3
before coding.
In Assignment-3.cpp, we provide implementations for functions such as updateStateOnAddr
and updateStateOnCopy
. These functions translate SVF Statements, including AddrStmt
, BinaryOpStmt
, CmpStmt
, LoadStmt
, etc.
Your task is to implement StoreStmt
and GepStmt
. The updateStateOnStore
function should store the RHS value at the memory address corresponding to the LHS value in AbstractState
which is from calling getAbsState
. Note that the RHS variable can be either IntervalValue
or AddressValue
.
The updateStateOnGep
function aims to compute the virtual address by adding an offset to the base pointer and then store the updated state in LHS value in AbstractState
which is from calling getAbsState
.
The handleCycle function needs enhancements to include widening and narrowing logic. This will enable the function to handle large loop bounds efficiently (e.g., for i = 0; i < 10000; ++i
), allowing it to exit the loop after several iterations and determine the correct value of i.
This task involves implementing two functions: recordObjSizeOnAddr
and detectBufOverflowOnGep
.
recordObjSizeOnAddr
records the allocated byte size for each AddrStmt
.
detectBufOverflowOnGep
updates the effective length of the variable associated with each GepStmt
. If a buffer overflow occurs, the function should throw an Assign3Exception
and call addBugToReporter
to log the bug in the final report.
Please submit Assignment-3.cpp via UNSW's WebCMS or give. Your implementation will be evaluated based on our 60 internal tests. You will receive full marks if your code passes all these tests. Note that our internal tests are not publicly available; we provide only limited test cases in Test3.cpp. You are encouraged to create additional test cases to verify the correctness of your implementation.
1. launch.json
You need to set the "program" to be the executable file of Assignment 3, i.e., "${workspaceFolder}/bin/assign-3"
in
launch.json in order to run and debug