1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.keystore.cts; 18 19 import android.test.AndroidTestCase; 20 import java.lang.reflect.Method; 21 22 public class PutOverflowTest extends AndroidTestCase { testCrash()23 public void testCrash() throws Exception { 24 try { 25 Class<?> keystoreClass = Class.forName("android.security.KeyStore"); 26 Method getInstance = keystoreClass.getMethod("getInstance"); 27 Method put = keystoreClass.getMethod("put", 28 String.class, byte[].class, int.class, int.class); 29 Object keystore = getInstance.invoke(null); 30 byte[] buffer = new byte[65536]; 31 Boolean result = (Boolean)put.invoke(keystore, "crashFile", buffer, -1, 0); 32 assertTrue("Fix for ANDROID-22802399 not present", result); 33 } catch (ReflectiveOperationException ignored) { 34 // Since this test requires reflection avoid causing undue failures if classes or 35 // methods were changed. 36 } 37 } 38 } 39