@@ -74,18 +74,30 @@ public abstract class TaintAbstractDomain
7474 private final TaintElement memory ;
7575
7676 /**
77- * Builds a taint abstract stack starting from a given stack and a list of
78- * elements that push taint . Builds a taint abstract stack starting from a
79- * given stack and a memory element.
77+ * Builds a taint abstract stack starting from a given stack and a taint
78+ * memory . Builds a taint abstract stack starting from a given stack and a
79+ * memory element.
8080 *
8181 * @param stack the stack of values
8282 * @param memory the memory element
8383 */
8484 protected TaintAbstractDomain (TaintElement [] stack , TaintElement memory ) {
85+ this (stack , 0 , 0 , memory );
86+ }
87+
88+ /**
89+ * Builds a taint abstract stack starting from a given stack, its head
90+ * index, its tail index and a taint memory. Builds a taint abstract stack
91+ * starting from a given stack and a memory element.
92+ *
93+ * @param stack the stack of values
94+ * @param memory the memory element
95+ */
96+ protected TaintAbstractDomain (TaintElement [] stack , int head , int tail , TaintElement memory ) {
8597 this .stack = stack ;
8698 this .memory = memory ;
87- this .head = 0 ;
88- this .tail = 0 ;
99+ this .head = head ;
100+ this .tail = tail ;
89101 }
90102
91103 @ Override
@@ -187,7 +199,7 @@ public TaintAbstractDomain smallStepSemantics(ValueExpression expression, Progra
187199 resultStack .popX (3 );
188200
189201 if (this .isTainted ((Statement ) pp ))
190- return mk (resultStack .stack , TaintElement .TAINT );
202+ return mk (resultStack .stack , resultStack . head , resultStack . tail , TaintElement .TAINT );
191203
192204 return resultStack ;
193205 }
@@ -233,7 +245,7 @@ else if (memory.isClean())
233245 TaintElement value = resultStack .pop ();
234246
235247 if (value .isTaint ())
236- return mk (resultStack .stack , TaintElement .TAINT );
248+ return mk (resultStack .stack , resultStack . head , resultStack . tail , TaintElement .TAINT );
237249 else if (value .isClean ())
238250 return resultStack ;
239251 }
@@ -749,7 +761,7 @@ public TaintAbstractDomain glbAux(TaintAbstractDomain other) throws SemanticExce
749761 for (int i = 0 ; i < STACK_LIMIT ; i ++) {
750762 result [i ] = this .get (i ).glb (other .get (i ));
751763 }
752- return mk (result , this .memory .glb (other .memory ));
764+ return mk (result , this .head , this . tail , this . memory .glb (other .memory ));
753765 }
754766
755767 /**
@@ -767,7 +779,7 @@ public TaintAbstractDomain lubAux(TaintAbstractDomain other) throws SemanticExce
767779 for (int i = 0 ; i < STACK_LIMIT ; i ++) {
768780 result [i ] = this .get (i ).lub (other .get (i ));
769781 }
770- return mk (result , this .memory .lub (other .memory ));
782+ return mk (result , this .head , this . tail , this . memory .lub (other .memory ));
771783 }
772784
773785 /**
@@ -859,7 +871,7 @@ public boolean hasBottomUntil(int x) {
859871 @ Override
860872 public TaintAbstractDomain clone () {
861873 TaintElement [] newArray = stack .clone ();
862- TaintAbstractDomain copy = mk (newArray , memory );
874+ TaintAbstractDomain copy = mk (newArray , head , tail , memory );
863875 copy .head = this .head ;
864876 copy .tail = this .tail ;
865877 return copy ;
@@ -955,12 +967,14 @@ else if (isTop())
955967
956968 /**
957969 * Utility for creating a concrete instance of {@link TaintAbstractDomain}
958- * given the stack and the memory.
970+ * given the stack, its head index, its tail index and the memory.
959971 *
960972 * @param stack the stack
973+ * @param head the head index
974+ * @param tail the tail index
961975 * @param memory the memory
962976 *
963977 * @return a new concrete instance of {@link TaintAbstractDomain}
964978 */
965- public abstract TaintAbstractDomain mk (TaintElement [] stack , TaintElement memory );
979+ public abstract TaintAbstractDomain mk (TaintElement [] stack , int head , int tail , TaintElement memory );
966980}
0 commit comments