Search in sources :

Example 1 with TaintedBooleanWithObjTag

use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag 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)

Example 2 with TaintedBooleanWithObjTag

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

the class NativeHelper method ensureIsBoxedObjTags.

@SuppressWarnings("rawtypes")
public static final Collection ensureIsBoxedObjTags(Collection in) {
    if (in != null) {
        Collection tmp = null;
        for (Object o : in) {
            if (o == null)
                break;
            Type t = Type.getType(o.getClass());
            if (t.getSort() == Type.ARRAY && t.getElementType().getSort() != Type.OBJECT) {
                if (tmp == null) {
                    try {
                        tmp = (Collection) in.getClass().getConstructor().newInstance(null);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                tmp.add$$PHOSPHORTAGGED(MultiDTaintedArrayWithObjTag.boxIfNecessary(o), new TaintedBooleanWithObjTag());
            } else
                break;
        }
        if (tmp != null) {
            in.clear();
            tmp.add$$PHOSPHORTAGGED(tmp, new TaintedBooleanWithObjTag());
        }
    }
    return in;
}
Also used : Type(org.objectweb.asm.Type) Collection(java.util.Collection) TaintedBooleanWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)

Example 3 with TaintedBooleanWithObjTag

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

the class NativeHelper method ensureIsUnBoxedImplicitTracking.

public static final Collection ensureIsUnBoxedImplicitTracking(Collection in) {
    if (in != null) {
        Collection tmp = null;
        for (Object o : in) {
            if (o != null && MultiDTaintedArrayWithObjTag.isPrimitiveBoxClass(o.getClass()) != null) {
                if (tmp == null) {
                    try {
                        tmp = (Collection) in.getClass().getConstructor().newInstance(null);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                tmp.add$$PHOSPHORTAGGED(MultiDTaintedArrayWithObjTag.unboxRaw(o), new ControlTaintTagStack(), new TaintedBooleanWithObjTag());
            } else
                break;
        }
        if (tmp != null) {
            in.clear();
            tmp.add$$PHOSPHORTAGGED(tmp, new ControlTaintTagStack(), new TaintedBooleanWithObjTag());
        }
    }
    return in;
}
Also used : ControlTaintTagStack(edu.columbia.cs.psl.phosphor.struct.ControlTaintTagStack) Collection(java.util.Collection) TaintedBooleanWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)

Example 4 with TaintedBooleanWithObjTag

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

the class NativeHelper method ensureIsUnBoxedObjTags.

public static final Collection ensureIsUnBoxedObjTags(Collection in) {
    if (in != null) {
        Collection tmp = null;
        for (Object o : in) {
            if (o != null && MultiDTaintedArrayWithObjTag.isPrimitiveBoxClass(o.getClass()) != null) {
                if (tmp == null) {
                    try {
                        tmp = (Collection) in.getClass().getConstructor().newInstance(null);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                tmp.add$$PHOSPHORTAGGED(MultiDTaintedArrayWithObjTag.unboxRaw(o), new TaintedBooleanWithObjTag());
            } else
                break;
        }
        if (tmp != null) {
            in.clear();
            tmp.add$$PHOSPHORTAGGED(tmp, new TaintedBooleanWithObjTag());
        }
    }
    return in;
}
Also used : Collection(java.util.Collection) TaintedBooleanWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)

Example 5 with TaintedBooleanWithObjTag

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

the class BoxedPrimitiveStoreWithObjTags method booleanValue.

public static TaintedBooleanWithObjTag booleanValue(Boolean z) {
    TaintedBooleanWithObjTag ret = new TaintedBooleanWithObjTag();
    ret.val = z;
    if (z.valueOf && tags.containsKey(z))
        ret.taint = tags.get(z);
    return ret;
}
Also used : TaintedBooleanWithObjTag(edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)

Aggregations

TaintedBooleanWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)7 Collection (java.util.Collection)4 Type (org.objectweb.asm.Type)3 ControlTaintTagStack (edu.columbia.cs.psl.phosphor.struct.ControlTaintTagStack)2 Taint (edu.columbia.cs.psl.phosphor.runtime.Taint)1 LazyArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayIntTags)1 LazyArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayObjTags)1 LazyBooleanArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayObjTags)1 LazyByteArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyByteArrayObjTags)1 LazyCharArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags)1 LazyDoubleArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayObjTags)1 LazyFloatArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags)1 LazyIntArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyIntArrayObjTags)1 LazyLongArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyLongArrayObjTags)1 LazyShortArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyShortArrayObjTags)1 TaintedBooleanWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag)1 TaintedByteWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedByteWithIntTag)1 TaintedByteWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedByteWithObjTag)1 TaintedCharWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedCharWithIntTag)1 TaintedCharWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedCharWithObjTag)1