src/jdk.jdwp.agent/share/native/libjdwp/invoker.c
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File bug_8160987.2 Cdiff src/jdk.jdwp.agent/share/native/libjdwp/invoker.c

src/jdk.jdwp.agent/share/native/libjdwp/invoker.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 341,360 **** --- 341,396 ---- request->available = JNI_TRUE; debugMonitorExit(invokerLock); } + /* + * Check that method is in the specified clazz or one of its super classes. + * We have to enforce this check at the JDWP layer because the JNI layer + * has different requirements. + */ + static jvmtiError check_methodClass(JNIEnv *env, jclass clazz, jmethodID method) + { + jclass containing_class; + jvmtiError error; + + error = JVMTI_FUNC_PTR(gdata->jvmti,GetMethodDeclaringClass) + (gdata->jvmti, method, &containing_class); + if (error != JVMTI_ERROR_NONE) { + return JVMTI_ERROR_NONE; /* Bad jmethodID ? This will be handled elsewhere */ + } + + if (JNI_FUNC_PTR(env,IsSameObject)(env, clazz, containing_class)) { + return JVMTI_ERROR_NONE; + } + + // If not the same class then check that containing_class is a super type of + // clazz and not an interface (hence it's a super class). + if (JNI_FUNC_PTR(env,IsAssignableFrom)(env, clazz, containing_class) && + referenceTypeTag(containing_class) != JDWP_TYPE_TAG(INTERFACE)) { + return JVMTI_ERROR_NONE; + } + return JVMTI_ERROR_INVALID_METHODID; + } + jvmtiError invoker_requestInvoke(jbyte invokeType, jbyte options, jint id, jthread thread, jclass clazz, jmethodID method, jobject instance, jvalue *arguments, jint argumentCount) { JNIEnv *env = getEnv(); InvokeRequest *request; jvmtiError error = JVMTI_ERROR_NONE; + if (invokeType == INVOKE_STATIC) { + error = check_methodClass(env, clazz, method); + if (error != JVMTI_ERROR_NONE) { + return error; + } + } + debugMonitorEnter(invokerLock); request = threadControl_getInvokeRequest(thread); if (request != NULL) { error = fillInvokeRequest(env, request, invokeType, options, id, thread, clazz, method, instance,
src/jdk.jdwp.agent/share/native/libjdwp/invoker.c
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File