private boolean isSafeValue(Location location, ConstantPoolGen cpg) throws CFGBuilderException { Instruction prevIns = location.getHandle().getInstruction(); if (prevIns instanceof LDC || prevIns instanceof GETSTATIC) return true; if (prevIns instanceof InvokeInstruction) { String methodName = ((InvokeInstruction) prevIns).getMethodName(cpg); if (methodName.startsWith("to") && methodName.endsWith("String") && methodName.length() > 8) return true; } if (prevIns instanceof AALOAD) { CFG cfg = classContext.getCFG(method); Location prev = getPreviousLocation(cfg, location, true); if (prev != null) { Location prev2 = getPreviousLocation(cfg, prev, true); if (prev2 != null && prev2.getHandle().getInstruction() instanceof GETSTATIC) { GETSTATIC getStatic = (GETSTATIC) prev2.getHandle().getInstruction(); if (getStatic.getSignature(cpg).equals("[Ljava/lang/String;")) return true; } } } return false; }
@Override public void visitAALOAD(AALOAD obj) { try { getFrame().popValue(); // array index // just transfer the taint from array to value at any index } catch (DataflowAnalysisException ex) { throw new InvalidBytecodeException("Not enough values on the stack", ex); } }
private boolean isArrayLoad(Instruction instruction) { return instruction instanceof AALOAD || instruction instanceof BALOAD || instruction instanceof CALOAD || instruction instanceof DALOAD || instruction instanceof FALOAD || instruction instanceof IALOAD || instruction instanceof LALOAD || instruction instanceof SALOAD; }
@SuppressWarnings("unused") // Called using reflection private Instruction createInstructionAaload(Element inst) throws IllegalXMLVMException { return new AALOAD(); }