Browse Source

Fix 487694: Race condition in annotation unpacking can surface through Spring AOP

tags/V1_8_9
Andy Clement 8 years ago
parent
commit
a17b28a1a9

BIN
bcel-builder/bcel-verifier.jar View File


BIN
bcel-builder/bcel.jar View File


+ 7
- 2
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeAnnos.java View File

@@ -71,12 +71,17 @@ public abstract class RuntimeAnnos extends Attribute {
}
}

private void inflate() {
try {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data));
int numberOfAnnotations = dis.readUnsignedShort();
for (int i = 0; i < numberOfAnnotations; i++) {
annotations.add(AnnotationGen.read(dis, getConstantPool(), visible));
if (numberOfAnnotations > 0) {
List<AnnotationGen> inflatedAnnotations = new ArrayList<AnnotationGen>();
for (int i = 0; i < numberOfAnnotations; i++) {
inflatedAnnotations.add(AnnotationGen.read(dis, getConstantPool(), visible));
}
annotations = inflatedAnnotations;
}
dis.close();
inflated = true;

+ 14
- 6
bcel-builder/src/org/aspectj/apache/bcel/classfile/annotation/RuntimeParamAnnos.java View File

@@ -87,13 +87,21 @@ public abstract class RuntimeParamAnnos extends Attribute {
try {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(annotation_data));
int numParameters = dis.readUnsignedByte();
for (int i=0; i<numParameters; i++) {
int numAnnotations = dis.readUnsignedShort();
AnnotationGen[] annotations = new AnnotationGen[numAnnotations];
for (int j=0; j<numAnnotations; j++) {
annotations[j] = AnnotationGen.read(dis,getConstantPool(),visible);
if (numParameters > 0) {
List<AnnotationGen[]> inflatedParameterAnnotations = new ArrayList<AnnotationGen[]>();
for (int i=0; i<numParameters; i++) {
int numAnnotations = dis.readUnsignedShort();
if (numAnnotations == 0 ) {
inflatedParameterAnnotations.add(AnnotationGen.NO_ANNOTATIONS);
} else {
AnnotationGen[] annotations = new AnnotationGen[numAnnotations];
for (int j=0; j<numAnnotations; j++) {
annotations[j] = AnnotationGen.read(dis,getConstantPool(),visible);
}
inflatedParameterAnnotations.add(annotations);
}
}
parameterAnnotations.add(annotations);
parameterAnnotations = inflatedParameterAnnotations;
}
inflated = true;
} catch (IOException ioe) {

BIN
lib/bcel/bcel-src.zip View File


BIN
lib/bcel/bcel-verifier.jar View File


BIN
lib/bcel/bcel.jar View File


+ 1
- 1
weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java View File

@@ -254,7 +254,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder {
org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = jc.getAnnotations();
bcelRepository.clear();
if (anns == null)
return new ResolvedType[0];
return ResolvedType.NONE;
ResolvedType[] ret = new ResolvedType[anns.length];
for (int i = 0; i < ret.length; i++) {
ret[i] = inWorld.resolve(UnresolvedType.forSignature(anns[i].getTypeSignature()));

Loading…
Cancel
Save