/** * Extract the number from a push operation (BIPUSH/SIPUSH). * * @param h Instruction Handle * @return The constant number if any is found */ public static Number getPushNumber(InstructionHandle h) { Instruction prevIns = h.getInstruction(); if (prevIns instanceof BIPUSH) { BIPUSH ldcCipher = (BIPUSH) prevIns; return ldcCipher.getValue(); } else if (prevIns instanceof SIPUSH) { SIPUSH ldcCipher = (SIPUSH) prevIns; return ldcCipher.getValue(); } return null; }
"getExpandedTypeID", "(I)I"); il.append(new SIPUSH((short)((Step)_left).getNodeType())); il.append(methodGen.loadDOM()); il.append(methodGen.loadContextNode());
/** * This constructor also applies for values of type short, char, byte * * @param cp Constant pool * @param value to be pushed */ public PUSH(ConstantPoolGen cp, int value) { if((value >= -1) && (value <= 5)) // Use ICONST_n instruction = INSTRUCTIONS[Constants.ICONST_0 + value]; else if((value >= -128) && (value <= 127)) // Use BIPUSH instruction = new BIPUSH((byte)value); else if((value >= -32768) && (value <= 32767)) // Use SIPUSH instruction = new SIPUSH((short)value); else // If everything fails create a Constant pool entry instruction = new LDC(cp.addInteger(value)); }
/** * This constructor also applies for values of type short, char, byte * * @param cp Constant pool * @param value to be pushed */ public PUSH(final ConstantPoolGen cp, final int value) { if ((value >= -1) && (value <= 5)) { instruction = InstructionConst.getInstruction(Const.ICONST_0 + value); } else if (Instruction.isValidByte(value)) { instruction = new BIPUSH((byte) value); } else if (Instruction.isValidShort(value)) { instruction = new SIPUSH((short) value); } else { instruction = new LDC(cp.addInteger(value)); } }
@Override public void visitSIPUSH(SIPUSH obj) { Number value = obj.getValue(); Constant c = new Constant(value); getFrame().pushValue(c); }
"getExpandedTypeID", "(I)I"); il.append(new SIPUSH((short)((Step)_left).getNodeType())); il.append(methodGen.loadDOM()); il.append(methodGen.loadContextNode());
public boolean isAssertionHandle(InstructionHandle handle, ConstantPoolGen cpg) { Instruction ins = handle.getInstruction(); if (isAssertionInstruction(ins, cpg)) { return true; } if (ins instanceof SIPUSH) { int v = ((SIPUSH) ins).getValue().intValue(); if (v == 500) { Instruction next = handle.getNext().getInstruction(); if (next instanceof INVOKEINTERFACE) { INVOKEINTERFACE iInterface = (INVOKEINTERFACE) next; String className = iInterface.getClassName(cpg); String fieldName = iInterface.getMethodName(cpg); if ("javax.servlet.http.HttpServletResponse".equals(className) && "setStatus".equals(fieldName)) { return true; } } } } return false; }
"getExpandedTypeID", "(I)I"); il.append(new SIPUSH((short)((Step)_left).getNodeType())); il.append(methodGen.loadDOM()); il.append(methodGen.loadContextNode());
public static int getValueOfNumber(Instruction ins, ConstantPoolGen cpg) { if (ins instanceof BIPUSH) { return ((BIPUSH) ins).getValue().intValue(); } else if (ins instanceof SIPUSH) { return ((SIPUSH) ins).getValue().intValue(); } else if (ins instanceof ICONST) { return ((ICONST) ins).getValue().intValue(); } else if (ins instanceof LDC_W) { LDC_W ldcw = (LDC_W) ins; return Integer.valueOf(ldcw.getValue(cpg).toString()); } else { return -1; } }
"getExpandedTypeID", "(I)I"); il.append(new SIPUSH((short)((Step)_left).getNodeType())); il.append(methodGen.loadDOM()); il.append(methodGen.loadContextNode());
/** * Extract the number from a push operation (BIPUSH/SIPUSH). * * @param h Instruction Handle * @return The constant number if any is found */ public static Number getPushNumber(InstructionHandle h) { Instruction prevIns = h.getInstruction(); if (prevIns instanceof BIPUSH) { BIPUSH ldcCipher = (BIPUSH) prevIns; return ldcCipher.getValue(); } else if (prevIns instanceof SIPUSH) { SIPUSH ldcCipher = (SIPUSH) prevIns; return ldcCipher.getValue(); } return null; }
break; case Const.SIPUSH: obj = new SIPUSH(); break; case Const.LDC:
@Override public void visitSIPUSH(SIPUSH obj) { Taint taint = new Taint(Taint.State.SAFE); // assume each pushed short is a char (for non-ASCII characters) taint.setConstantValue(String.valueOf((char) obj.getValue().shortValue())); getFrame().pushValue(taint); }
break; case Const.SIPUSH: ins = new SIPUSH(r.nextShort(Short.MIN_VALUE, Short.MAX_VALUE)); break; case Const.LDC:
@Override public void visitSIPUSH(SIPUSH obj) { Taint taint = new Taint(Taint.State.SAFE); // assume each pushed short is a char (for non-ASCII characters) taint.setConstantValue(String.valueOf((char) obj.getValue().shortValue())); getFrame().pushValue(taint); }
@Override public void visitSIPUSH(SIPUSH obj) { Number value = obj.getValue(); Constant c = new Constant(value); getFrame().pushValue(c); }
public boolean isAssertionHandle(InstructionHandle handle, ConstantPoolGen cpg) { Instruction ins = handle.getInstruction(); if (isAssertionInstruction(ins, cpg)) { return true; } if (ins instanceof SIPUSH) { int v = ((SIPUSH) ins).getValue().intValue(); if (v == 500) { Instruction next = handle.getNext().getInstruction(); if (next instanceof INVOKEINTERFACE) { INVOKEINTERFACE iInterface = (INVOKEINTERFACE) next; String className = iInterface.getClassName(cpg); String fieldName = iInterface.getMethodName(cpg); if ("javax.servlet.http.HttpServletResponse".equals(className) && "setStatus".equals(fieldName)) { return true; } } } } return false; }
push = ((BIPUSH) handles[i + 1].getInstruction()).getValue().intValue(); } else if (handles[i + 1].getInstruction() instanceof SIPUSH) { push = ((SIPUSH) handles[i + 1].getInstruction()).getValue().intValue(); } else { push = ((ICONST) handles[i + 1].getInstruction()).getValue().intValue();