-
Notifications
You must be signed in to change notification settings - Fork 3
/
primitive.py
69 lines (57 loc) · 1.58 KB
/
primitive.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#coding=utf-8
class Operation:
def __init__(self):
self.pname = ''
self.pnum = -1
self.op_type = 'M'
self.op_index = -1
self.interesting_for_split = 0
## malloc
self.malloc_size = -1
self.malloc_target = None
self.malloc_taint = True
self.malloc_chunk_addr = -1
## free
self.free_target = None
self.free_malloc_index = -1
self.free_chunk_size = -1
self.free_chunk_addr = -1
def __str__(self):
x = ''
if self.op_type == 'M':
x += 'm('
x += str(self.malloc_size)
x += ')'
else:
x += 'f('
x += str(self.free_target)
x += ', '
x += str(self.free_malloc_index)
x += ','
x += str(self.free_chunk_size)
x += ','
x += str(self.free_chunk_addr)
x += ')'
return x
class Primitive:
def __init__(self):
self.operation_list = []
self.operation_len = 0
self.prim_name = None
def __str__(self):
x = ''
for each_op in self.operation_list:
x += str(each_op)
x += " --> "
return x
def get_str_primitve(self):
prim_str = self.__str__()
return prim_str
def add_operation(self, op):
self.operation_list.append(op)
self.operation_len += 1
def del_operation(self, op):
if op not in self.operation_list:
return
self.operation_list.remove(op)
self.operation_len -= 1