diff options
| -rw-r--r-- | runtime/verifier/method_verifier.cc | 2 | ||||
| -rw-r--r-- | test/600-verifier-fails/expected.txt | 1 | ||||
| -rw-r--r-- | test/600-verifier-fails/info.txt | 4 | ||||
| -rw-r--r-- | test/600-verifier-fails/smali/sput.smali | 23 | ||||
| -rw-r--r-- | test/600-verifier-fails/src/Main.java | 30 |
5 files changed, 59 insertions, 1 deletions
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 2b96328f80..b2be770bf7 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -4652,7 +4652,7 @@ void MethodVerifier::VerifyISFieldAccess(const Instruction* inst, const RegType& if (field->IsFinal() && field->GetDeclaringClass() != GetDeclaringClass().GetClass()) { Fail(VERIFY_ERROR_ACCESS_FIELD) << "cannot modify final field " << PrettyField(field) << " from other class " << GetDeclaringClass(); - return; + // Keep hunting for possible hard fails. } } diff --git a/test/600-verifier-fails/expected.txt b/test/600-verifier-fails/expected.txt new file mode 100644 index 0000000000..b0aad4deb5 --- /dev/null +++ b/test/600-verifier-fails/expected.txt @@ -0,0 +1 @@ +passed diff --git a/test/600-verifier-fails/info.txt b/test/600-verifier-fails/info.txt new file mode 100644 index 0000000000..478dd9bceb --- /dev/null +++ b/test/600-verifier-fails/info.txt @@ -0,0 +1,4 @@ +The situation in this test was discovered by running dexfuzz on +another fuzzingly random generated Java test. The soft verification +fail (on the final field modification) should not hide the hard +verification fail (on the type mismatch) to avoid a crash later on. diff --git a/test/600-verifier-fails/smali/sput.smali b/test/600-verifier-fails/smali/sput.smali new file mode 100644 index 0000000000..87f3799e02 --- /dev/null +++ b/test/600-verifier-fails/smali/sput.smali @@ -0,0 +1,23 @@ +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.class public LA; +.super Ljava/lang/Object; + +.method public foo(I)V +.registers 2 + sput v1, LMain;->staticField:Ljava/lang/String; + return-void +.end method diff --git a/test/600-verifier-fails/src/Main.java b/test/600-verifier-fails/src/Main.java new file mode 100644 index 0000000000..ba4cc31ad7 --- /dev/null +++ b/test/600-verifier-fails/src/Main.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.lang.reflect.Method; + +public class Main { + + public static final String staticField = null; + + public static void main(String[] args) throws Exception { + try { + Class<?> a = Class.forName("A"); + } catch (java.lang.VerifyError e) { + System.out.println("passed"); + } + } +} |