public void jimplify (DexBody body) { if(!(instruction instanceof Instruction12x)) throw new IllegalArgumentException("Expected Instruction12x but got: "+instruction.getClass()); Instruction12x lengthOfArrayInstruction = (Instruction12x)instruction; int dest = lengthOfArrayInstruction.getRegisterA(); Local arrayReference = body.getRegisterLocal(lengthOfArrayInstruction.getRegisterB()); LengthExpr lengthExpr = Jimple.v().newLengthExpr(arrayReference); assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), lengthExpr); setUnit(assign); addTags(assign); body.add(assign); if (IDalvikTyper.ENABLE_DVKTYPER) { Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign); DalvikTyper.v().setType(assign.getLeftOpBox(), IntType.v(), false); } }
public void caseLengthExpr(LengthExpr v) { String oldName = varName; Value op = v.getOp(); suggestVariableName("op"); String opName = varName; op.apply(this); p.println("Value "+oldName+" = Jimple.v().newLengthExpr("+opName+");"); varName = oldName; }
@Override public void caseLengthExpr(LengthExpr le) { Value array = le.getOp(); constantV.setOrigStmt(origStmt); // In buggy code, the parameter could be a NullConstant. // This is why we use .asImmediate() and not .asLocal() Register arrayReg = regAlloc.asImmediate(array, constantV); stmtV.addInsn(new Insn12x(Opcode.ARRAY_LENGTH, destinationReg, arrayReg), origStmt); }
private void javafy_unop_expr(ValueBox vb) { UnopExpr uoe = (UnopExpr) vb.getValue(); javafy(uoe.getOpBox()); if (uoe instanceof LengthExpr) vb.setValue(new DLengthExpr(((LengthExpr) uoe).getOp())); else if (uoe instanceof NegExpr) vb.setValue(new DNegExpr(((NegExpr) uoe).getOp())); }
@Override public void caseLengthExpr(LengthExpr arg0) { this.isLeftHandSide = false; arg0.getOp().apply(this); Expression base = this.getExpression(); this.stmtSwitch.getErrorModel().createNonNullGuard(base); this.expressionStack .push(GlobalsCache.v().getArraySizeExpression(base)); }
@Override public void visit(Value e) { if (e instanceof LengthExpr) { LengthExpr le = (LengthExpr) e; add(e, le.getOp()); } }
/** * It is supposed that it is not neccessay to treat the length expression since * it always comes with the corresponding array and the level of the array (which is * the same as its length level) will always be already treated. * @param v length expression */ @Override public void caseLengthExpr(LengthExpr v) { rightElement = RightElement.NOT; logger.finest("LengthExpr identified: " + v.toString()); // if (actualContext == StmtContext.ASSIGNRIGHT) { // // JimpleInjector.addLevelInAssignStmt(v, callingStmt); // System.out.println(v.getType()); // System.out.println(v.getUseBoxes().get(0).toString()); // // new InternalAnalyzerException(); // } else { // new InternalAnalyzerException(); // } }
@Override public void caseLengthExpr(LengthExpr v) { throw new RuntimeException("todo"); }
public void caseLengthExpr(LengthExpr expr) { result = result.add(mgr.NULL_POINTER_EXCEPTION); result = result.add(mightThrow(expr.getOp())); }
@Override public void caseLengthExpr(LengthExpr v) { throwInvalidWriteException(v); }
@Override public void caseLengthExpr(LengthExpr v) { handleUnaryExpr(v.getOp()); }
/** * The method should update the <em>security level</em> of an expression * with type {@link LengthExpr}, but it is not possible to update the level * of such an expression. * * @param v * The expression for which the <em>security level</em> should be * updated. * @see soot.jimple.ExprSwitch#caseLengthExpr(soot.jimple.LengthExpr) * @throws InvalidSwitchException * Always, because the update is not possible. */ @Override public void caseLengthExpr(LengthExpr v) { throw new SwitchException(getMsg("exception.analysis.switch.update_error", this.getClass().getSimpleName(), v.getClass().getSimpleName(), v.toString(), getSourceLine())); }
/** * DOC * * @see soot.jimple.ExprSwitch#caseLengthExpr(soot.jimple.LengthExpr) */ @Override public void caseLengthExpr(LengthExpr v) { v.getOp().apply(this); }
/** * Looks up the <em>security level</em> for the given length expression and * stores the level in {@link SecurityLevelValueReadSwitch#level}. The * resulting level is the level of the array. * * @param v * The length expression for which the <em>security level</em> * should be looked up. * @see soot.jimple.ExprSwitch#caseLengthExpr(soot.jimple.LengthExpr) * @see SecurityLevelValueReadSwitch#handleUnaryOperation(UnopExpr) */ @Override public void caseLengthExpr(LengthExpr v) { handleUnaryOperation(v); }