changeset 138:29314732135b

8075668: new DeviceMgmtPermission("*:*", ", open, register, unregister,") does not result in IAE . Summary: Empty token case is managed specially Reviewed-by: alkonsta
author snazarki
date Tue, 24 Mar 2015 11:27:34 +0300
parents 133a8266a5ac
children e68afdf9b782
files src/share/classes/com/oracle/dio/utils/ActionFactory.java
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/oracle/dio/utils/ActionFactory.java	Mon Mar 23 13:32:55 2015 +0300
+++ b/src/share/classes/com/oracle/dio/utils/ActionFactory.java	Tue Mar 24 11:27:34 2015 +0300
@@ -83,14 +83,28 @@
      * @return true for valid
      */
     private static boolean isValidAction(String actions, String normalizedList) {
-        StringTokenizer tokez = new StringTokenizer(actions, ",");
+        StringTokenizer tokez = new StringTokenizer(actions, ",", true);
+        // detect first empty token
+        boolean lastTokenIsComma = true;
         while (tokez.hasMoreElements()) {
             String action = tokez.nextToken();
+            // special case for empty actions that are not returned by StringTokenizer.nextToken() by default
+            if (action.equals(",")) {
+                if (lastTokenIsComma) {
+                    return false;
+                } else {
+                    lastTokenIsComma = true;
+                    continue;
+                }
+            } else {
+                lastTokenIsComma = false;
+            }
             if (!isIncluded(action, normalizedList)) {
                 return false;
             }
         }
-        return true;
+        // detects last empty token as well
+        return !lastTokenIsComma;
     }
 
     /**