8170966: Right parenthesis issue
Reviewed-by: acorn, ctornqvi, mschoene
Contributed-by: harold.seigel@oracle.com
--- a/jdk/src/java.base/share/native/libverify/check_code.c Fri Nov 18 10:27:13 2016 -0800
+++ b/jdk/src/java.base/share/native/libverify/check_code.c Wed Dec 21 10:15:49 2016 -0500
@@ -459,6 +459,8 @@
static fullinfo_type cp_index_to_class_fullinfo(context_type *, int, int);
+static const char* get_result_signature(const char* signature);
+
static char signature_to_fieldtype(context_type *context,
const char **signature_p, fullinfo_type *info);
@@ -2789,7 +2791,7 @@
operand);
const char *result_signature;
check_and_push(context, signature, VM_STRING_UTF);
- result_signature = strchr(signature, JVM_SIGNATURE_ENDFUNC);
+ result_signature = get_result_signature(signature);
if (result_signature++ == NULL) {
CCerror(context, "Illegal signature %s", signature);
}
@@ -3712,6 +3714,42 @@
longjmp(context->jump_buffer, 1);
}
+/*
+ * Need to scan the entire signature to find the result type because
+ * types in the arg list and the result type could contain embedded ')'s.
+ */
+static const char* get_result_signature(const char* signature) {
+ const char *p;
+ for (p = signature; *p != JVM_SIGNATURE_ENDFUNC; p++) {
+ switch (*p) {
+ case JVM_SIGNATURE_BOOLEAN:
+ case JVM_SIGNATURE_BYTE:
+ case JVM_SIGNATURE_CHAR:
+ case JVM_SIGNATURE_SHORT:
+ case JVM_SIGNATURE_INT:
+ case JVM_SIGNATURE_FLOAT:
+ case JVM_SIGNATURE_DOUBLE:
+ case JVM_SIGNATURE_LONG:
+ case JVM_SIGNATURE_FUNC: /* ignore initial (, if given */
+ break;
+ case JVM_SIGNATURE_CLASS:
+ while (*p != JVM_SIGNATURE_ENDCLASS) p++;
+ break;
+ case JVM_SIGNATURE_ARRAY:
+ while (*p == JVM_SIGNATURE_ARRAY) p++;
+ /* If an array of classes, skip over class name, too. */
+ if (*p == JVM_SIGNATURE_CLASS) {
+ while (*p != JVM_SIGNATURE_ENDCLASS) p++;
+ }
+ break;
+ default:
+ /* Indicate an error. */
+ return NULL;
+ }
+ }
+ return p++; /* skip over ')'. */
+}
+
static char
signature_to_fieldtype(context_type *context,
const char **signature_p, fullinfo_type *full_info_p)