changeset 38585:4e6b93b00caa

8152207: Perform array bound checks while getting a length of bytecode instructions Reviewed-by: hseigel
author asmotrak
date Fri, 27 May 2016 14:24:38 -0700
parents 96ea53771693
children a4c2c26a296a
files jdk/src/java.base/share/native/libverify/check_code.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/native/libverify/check_code.c	Fri May 27 14:02:28 2016 -0300
+++ b/jdk/src/java.base/share/native/libverify/check_code.c	Fri May 27 14:24:38 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -1744,9 +1744,14 @@
             }
 
         default: {
+            if (instruction < 0 || instruction > JVM_OPC_MAX)
+                return -1;
+
             /* A length of 0 indicates an error. */
-            int length = opcode_length[instruction];
-            return (length <= 0) ? -1 : length;
+            if (opcode_length[instruction] <= 0)
+                return -1;
+
+            return opcode_length[instruction];
         }
     }
 }