Search in sources :

Example 1 with LazyCharArrayObjTags

use of edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags in project phosphor by gmu-swe.

the class UninstArrayReflectionMasker method setChar$$PHOSPHORTAGGED.

public static void setChar$$PHOSPHORTAGGED(Object obj, Taint idxTaint, int idx, Taint taint, char val) {
    if (obj instanceof LazyCharArrayObjTags) {
        LazyCharArrayObjTags a = (LazyCharArrayObjTags) obj;
        a.set(a.val, idx, taint, val);
    } else
        throw new ArrayStoreException("Called setX, but don't have tainted X array!");
}
Also used : LazyCharArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags)

Example 2 with LazyCharArrayObjTags

use of edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags in project phosphor by gmu-swe.

the class UninstArrayReflectionMasker method newInstance$$PHOSPHORTAGGED.

public static Object newInstance$$PHOSPHORTAGGED(Class clazz, Object lenTaint, int len) {
    Class tmp = clazz;
    int dims = 0;
    while (tmp.isArray()) {
        tmp = tmp.getComponentType();
        dims++;
    }
    if (tmp.isPrimitive()) {
        // else
        if (dims == 0) {
            if (tmp == Double.TYPE)
                return new LazyDoubleArrayObjTags(new double[len]);
            if (tmp == Float.TYPE)
                return new LazyFloatArrayObjTags(new float[len]);
            if (tmp == Integer.TYPE)
                return new LazyIntArrayObjTags(new int[len]);
            if (tmp == Long.TYPE)
                return new LazyLongArrayObjTags(new long[len]);
            if (tmp == Short.TYPE)
                return new LazyShortArrayObjTags(new short[len]);
            if (tmp == Boolean.TYPE)
                return new LazyBooleanArrayObjTags(new boolean[len]);
            if (tmp == Byte.TYPE)
                return new LazyByteArrayObjTags(new byte[len]);
            if (tmp == Character.TYPE)
                return new LazyCharArrayObjTags(new char[len]);
        } else
            clazz = MultiDTaintedArrayWithObjTag.getUnderlyingBoxClassForUnderlyingClass(clazz);
    }
    return Array.newInstance(clazz, len);
}
Also used : LazyLongArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyLongArrayObjTags) LazyByteArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyByteArrayObjTags) LazyIntArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyIntArrayObjTags) LazyCharArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags) LazyDoubleArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayObjTags) LazyShortArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyShortArrayObjTags) LazyBooleanArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayObjTags) LazyFloatArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags)

Example 3 with LazyCharArrayObjTags

use of edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags in project phosphor by gmu-swe.

the class ArrayReflectionMasker method newInstance$$PHOSPHORTAGGED.

public static Object newInstance$$PHOSPHORTAGGED(Class clazz, Taint lenTaint, int len) {
    Class tmp = clazz;
    int dims = 0;
    while (tmp.isArray()) {
        tmp = tmp.getComponentType();
        dims++;
    }
    if (tmp.isPrimitive()) {
        // else
        if (dims == 0) {
            if (tmp == Double.TYPE)
                return new LazyDoubleArrayObjTags(new double[len]);
            if (tmp == Float.TYPE)
                return new LazyFloatArrayObjTags(new float[len]);
            if (tmp == Integer.TYPE)
                return new LazyIntArrayObjTags(new int[len]);
            if (tmp == Long.TYPE)
                return new LazyLongArrayObjTags(new long[len]);
            if (tmp == Short.TYPE)
                return new LazyShortArrayObjTags(new short[len]);
            if (tmp == Boolean.TYPE)
                return new LazyBooleanArrayObjTags(new boolean[len]);
            if (tmp == Byte.TYPE)
                return new LazyByteArrayObjTags(new byte[len]);
            if (tmp == Character.TYPE)
                return new LazyCharArrayObjTags(new char[len]);
        } else
            clazz = MultiDTaintedArrayWithObjTag.getUnderlyingBoxClassForUnderlyingClass(clazz);
    }
    return Array.newInstance(clazz, len);
}
Also used : LazyLongArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyLongArrayObjTags) LazyByteArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyByteArrayObjTags) LazyIntArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyIntArrayObjTags) LazyCharArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags) LazyDoubleArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayObjTags) LazyShortArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyShortArrayObjTags) LazyBooleanArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayObjTags) LazyFloatArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags)

Example 4 with LazyCharArrayObjTags

use of edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags in project phosphor by gmu-swe.

the class ArrayReflectionMasker method setChar$$PHOSPHORTAGGED.

public static void setChar$$PHOSPHORTAGGED(Object obj, Taint idxTaint, int idx, Taint taint, char val) {
    if (obj instanceof LazyCharArrayObjTags) {
        LazyCharArrayObjTags a = (LazyCharArrayObjTags) obj;
        a.set(a.val, idx, taint, val);
    } else
        throw new ArrayStoreException("Called setX, but don't have tainted X array!");
}
Also used : LazyCharArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags)

Example 5 with LazyCharArrayObjTags

use of edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags in project phosphor by gmu-swe.

the class MultiDTaintedArrayWithObjTag method boxIfNecessary.

public static final Object boxIfNecessary(final Object in, final HashSet<Object> done) {
    if (in != null && in.getClass().isArray()) {
        if (in.getClass().getComponentType().isPrimitive()) {
            // Is prim arraytype
            Class tmp = in.getClass();
            int dims = 0;
            while (tmp.isArray()) {
                tmp = tmp.getComponentType();
                dims++;
            }
            if (dims > 1) {
                // this should never be possible.
                Type t = Type.getType(in.getClass());
                initWithEmptyTaints((Object[]) in, t.getElementType().getSort(), t.getDimensions());
            } else {
                if (tmp == Boolean.TYPE)
                    return new LazyBooleanArrayObjTags((boolean[]) in);
                if (tmp == Byte.TYPE)
                    return new LazyByteArrayObjTags(((byte[]) in));
                if (tmp == Character.TYPE)
                    return new LazyCharArrayObjTags(((char[]) in));
                if (tmp == Double.TYPE)
                    return new LazyDoubleArrayObjTags(((double[]) in));
                if (tmp == Float.TYPE)
                    return new LazyFloatArrayObjTags(((float[]) in));
                if (tmp == Integer.TYPE)
                    return new LazyIntArrayObjTags(((int[]) in));
                if (tmp == Long.TYPE)
                    return new LazyLongArrayObjTags(((long[]) in));
                if (tmp == Short.TYPE)
                    return new LazyShortArrayObjTags(((short[]) in));
                throw new IllegalArgumentException();
            }
        } else if (in.getClass().getComponentType().isArray() && in.getClass().getComponentType().getComponentType().isPrimitive()) {
            // THIS array is an prim[][] array
            Object[] _in = (Object[]) in;
            Class tmp = in.getClass();
            while (tmp.isArray()) {
                tmp = tmp.getComponentType();
            }
            if (tmp == Boolean.TYPE) {
                LazyBooleanArrayObjTags[] ret = new LazyBooleanArrayObjTags[_in.length];
                for (int i = 0; i < _in.length; i++) ret[i] = new LazyBooleanArrayObjTags((boolean[]) _in[i]);
                return ret;
            }
            if (tmp == Byte.TYPE) {
                LazyByteArrayObjTags[] ret = new LazyByteArrayObjTags[_in.length];
                for (int i = 0; i < _in.length; i++) ret[i] = new LazyByteArrayObjTags((byte[]) _in[i]);
                return ret;
            }
            if (tmp == Character.TYPE) {
                LazyCharArrayObjTags[] ret = new LazyCharArrayObjTags[_in.length];
                for (int i = 0; i < _in.length; i++) ret[i] = new LazyCharArrayObjTags((char[]) _in[i]);
                return ret;
            }
            if (tmp == Double.TYPE) {
                LazyDoubleArrayObjTags[] ret = new LazyDoubleArrayObjTags[_in.length];
                for (int i = 0; i < _in.length; i++) ret[i] = new LazyDoubleArrayObjTags((double[]) _in[i]);
                return ret;
            }
            if (tmp == Float.TYPE) {
                LazyFloatArrayObjTags[] ret = new LazyFloatArrayObjTags[_in.length];
                for (int i = 0; i < _in.length; i++) ret[i] = new LazyFloatArrayObjTags((float[]) _in[i]);
                return ret;
            }
            if (tmp == Integer.TYPE) {
                LazyIntArrayObjTags[] ret = new LazyIntArrayObjTags[_in.length];
                for (int i = 0; i < _in.length; i++) ret[i] = new LazyIntArrayObjTags((int[]) _in[i]);
                return ret;
            }
            if (tmp == Short.TYPE) {
                LazyShortArrayObjTags[] ret = new LazyShortArrayObjTags[_in.length];
                for (int i = 0; i < _in.length; i++) ret[i] = new LazyShortArrayObjTags((short[]) _in[i]);
                return ret;
            }
            if (tmp == Long.TYPE) {
                LazyLongArrayObjTags[] ret = new LazyLongArrayObjTags[_in.length];
                for (int i = 0; i < _in.length; i++) ret[i] = new LazyLongArrayObjTags((long[]) _in[i]);
                return ret;
            }
            throw new UnsupportedOperationException();
        } else if (in.getClass().getComponentType().getName().equals("java.lang.Object")) {
            Object[] _in = (Object[]) in;
            TaintedBooleanWithObjTag tmpRet = new TaintedBooleanWithObjTag();
            for (int i = 0; i < _in.length; i++) {
                if (done.add$$PHOSPHORTAGGED(_in[i], tmpRet).val)
                    _in[i] = boxIfNecessary(_in[i], done);
            }
        }
    }
    return in;
}
Also used : LazyByteArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyByteArrayObjTags) LazyLongArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyLongArrayObjTags) LazyCharArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags) Taint(edu.columbia.cs.psl.phosphor.runtime.Taint) LazyFloatArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags) Type(org.objectweb.asm.Type) LazyIntArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyIntArrayObjTags) LazyDoubleArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayObjTags) LazyShortArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyShortArrayObjTags) TaintedBooleanWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag) LazyBooleanArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayObjTags)

Aggregations

LazyCharArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags)7 LazyBooleanArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayObjTags)5 LazyByteArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyByteArrayObjTags)5 LazyDoubleArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayObjTags)5 LazyFloatArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags)5 LazyIntArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyIntArrayObjTags)5 LazyLongArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyLongArrayObjTags)5 LazyShortArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyShortArrayObjTags)5 Taint (edu.columbia.cs.psl.phosphor.runtime.Taint)3 Type (org.objectweb.asm.Type)2 LazyArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayObjTags)1 TaintedBooleanWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)1 HashSet (java.util.HashSet)1