Skip to content

Commit fb699b3

Browse files
committed
feat: optimizations in smallStepSemantics
1 parent d03199a commit fb699b3

File tree

1 file changed

+10
-77
lines changed

1 file changed

+10
-77
lines changed

src/main/java/it/unipr/analysis/taint/TaintAbstractDomain.java

Lines changed: 10 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -195,38 +195,14 @@ public TaintAbstractDomain smallStepSemantics(ValueExpression expression, Progra
195195
return resultStack;
196196
}
197197

198-
case "MstoreOperator": { // MSTORE
198+
case "MstoreOperator":
199+
case "Mstore8Operator":
200+
case "SstoreOperator": { // pops 2
199201
if (hasBottomUntil(2))
200202
return bottom();
201203
TaintAbstractDomain resultStack = clone();
202-
203-
TaintElement offset = resultStack.pop();
204-
TaintElement value = resultStack.pop();
205-
206-
if (resultStack.isEmpty())
207-
return bottom();
208-
else
209-
return resultStack;
210-
}
211-
case "Mstore8Operator": { // MSTORE8
212-
if (hasBottomUntil(2))
213-
return bottom();
214-
TaintAbstractDomain resultStack = clone();
215-
216-
TaintElement offset = resultStack.pop();
217-
TaintElement value = resultStack.pop();
218-
219-
if (resultStack.isEmpty())
220-
return bottom();
221-
else
222-
return resultStack;
223-
}
224-
case "SstoreOperator": { // SSTORE
225-
if (hasBottomUntil(2))
226-
return bottom();
227-
TaintAbstractDomain resultStack = clone();
228-
TaintElement key = resultStack.pop();
229-
TaintElement value = resultStack.pop();
204+
resultStack.pop();
205+
resultStack.pop();
230206

231207
if (resultStack.isEmpty())
232208
return bottom();
@@ -440,8 +416,8 @@ public TaintAbstractDomain smallStepSemantics(ValueExpression expression, Progra
440416
else
441417
return resultStack;
442418
}
443-
case "CallOperator": { // CALL
444-
// At the moment, we do not handle CALL
419+
case "CallOperator":
420+
case "CallcodeOperator": { // pops 7, push 1
445421
if (hasBottomUntil(7))
446422
return bottom();
447423
TaintAbstractDomain resultStack = clone();
@@ -453,28 +429,6 @@ public TaintAbstractDomain smallStepSemantics(ValueExpression expression, Progra
453429
TaintElement outOffset = resultStack.pop();
454430
TaintElement outLength = resultStack.pop();
455431

456-
// resultStack.push(StackElement.NOT_JUMPDEST_TOP);
457-
resultStack.push(TaintElement.TOP);
458-
459-
if (resultStack.isEmpty())
460-
return bottom();
461-
else
462-
return resultStack;
463-
}
464-
case "CallcodeOperator": { // CALLCODE
465-
// At the moment, we do not handle CALLCODE
466-
if (hasBottomUntil(7))
467-
return bottom();
468-
TaintAbstractDomain resultStack = clone();
469-
TaintElement gas = resultStack.pop();
470-
TaintElement to = resultStack.pop();
471-
TaintElement value = resultStack.pop();
472-
TaintElement inOffset = resultStack.pop();
473-
TaintElement inLength = resultStack.pop();
474-
TaintElement outOffset = resultStack.pop();
475-
TaintElement outLength = resultStack.pop();
476-
477-
// resultStack.push(StackElement.NOT_JUMPDEST_TOP);
478432
resultStack.push(TaintElement.TOP);
479433

480434
if (resultStack.isEmpty())
@@ -495,8 +449,8 @@ public TaintAbstractDomain smallStepSemantics(ValueExpression expression, Progra
495449
else
496450
return resultStack;
497451
}
498-
case "DelegatecallOperator": { // DELEGATECALL
499-
// At the moment, we do not handle DELEGATECALL
452+
case "DelegatecallOperator":
453+
case "StaticcallOperator": { // pops 6, push 1
500454
if (hasBottomUntil(6))
501455
return bottom();
502456
TaintAbstractDomain resultStack = clone();
@@ -506,28 +460,7 @@ public TaintAbstractDomain smallStepSemantics(ValueExpression expression, Progra
506460
TaintElement inLength = resultStack.pop();
507461
TaintElement outOffset = resultStack.pop();
508462
TaintElement outLength = resultStack.pop();
509-
510-
// resultStack.push(StackElement.NOT_JUMPDEST_TOP);
511-
resultStack.push(TaintElement.TOP);
512-
513-
if (resultStack.isEmpty())
514-
return bottom();
515-
else
516-
return resultStack;
517-
}
518-
case "StaticcallOperator": { // STATICCALL
519-
// At the moment, we do not handle STATICCALL
520-
if (hasBottomUntil(6))
521-
return bottom();
522-
TaintAbstractDomain resultStack = clone();
523-
TaintElement gas = resultStack.pop();
524-
TaintElement to = resultStack.pop();
525-
TaintElement inOffset = resultStack.pop();
526-
TaintElement inLength = resultStack.pop();
527-
TaintElement outOffset = resultStack.pop();
528-
TaintElement outLength = resultStack.pop();
529-
530-
// resultStack.push(StackElement.NOT_JUMPDEST_TOP);
463+
531464
resultStack.push(TaintElement.TOP);
532465

533466
if (resultStack.isEmpty())

0 commit comments

Comments
 (0)