diff options
| author | Ivan Gerasimov <igerasim@openjdk.org> | 2019-10-16 14:32:17 -0700 |
|---|---|---|
| committer | Ivan Gerasimov <igerasim@openjdk.org> | 2019-10-16 14:32:17 -0700 |
| commit | 31afddccae9b540b896867a46b1084367b7ff5fd (patch) | |
| tree | ed8397f01ca53cf8e6aeba08f0eb595519bd698e /src/java.base/share/classes/java/io/FilePermission.java | |
| parent | 7e6ebde13c1a65e8fda6c6bc951c6136f0d7b665 (diff) | |
| download | openjdk-31afddccae9b540b896867a46b1084367b7ff5fd.tar.gz openjdk-31afddccae9b540b896867a46b1084367b7ff5fd.zip | |
8230407: SocketPermission and FilePermission action list allows leading comma
Co-authored-by: Chris Hegarty <chris.hegarty@oracle.com>
Reviewed-by: chegar
Diffstat (limited to 'src/java.base/share/classes/java/io/FilePermission.java')
| -rw-r--r-- | src/java.base/share/classes/java/io/FilePermission.java | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/java.base/share/classes/java/io/FilePermission.java b/src/java.base/share/classes/java/io/FilePermission.java index 97eb3082fe2..eec9a788c88 100644 --- a/src/java.base/share/classes/java/io/FilePermission.java +++ b/src/java.base/share/classes/java/io/FilePermission.java @@ -480,9 +480,9 @@ public final class FilePermission extends Permission implements Serializable { * @param path the pathname of the file/directory. * @param actions the action string. * - * @throws IllegalArgumentException - * If actions is {@code null}, empty or contains an action - * other than the specified possible actions. + * @throws IllegalArgumentException if actions is {@code null}, empty, + * malformed or contains an action other than the specified + * possible actions */ public FilePermission(String path, String actions) { super(path); @@ -935,17 +935,18 @@ public final class FilePermission extends Permission implements Serializable { } // make sure we didn't just match the tail of a word - // like "ackbarfaccept". Also, skip to the comma. + // like "ackbarfdelete". Also, skip to the comma. boolean seencomma = false; while (i >= matchlen && !seencomma) { - switch(a[i-matchlen]) { - case ',': - seencomma = true; - break; + switch (c = a[i-matchlen]) { case ' ': case '\r': case '\n': case '\f': case '\t': break; default: + if (c == ',' && i > matchlen) { + seencomma = true; + break; + } throw new IllegalArgumentException( "invalid permission: " + actions); } @@ -1141,10 +1142,10 @@ final class FilePermissionCollection extends PermissionCollection * * @param permission the Permission object to add. * - * @throws IllegalArgumentException - if the permission is not a + * @throws IllegalArgumentException if the permission is not a * FilePermission * - * @throws SecurityException - if this FilePermissionCollection object + * @throws SecurityException if this FilePermissionCollection object * has been marked readonly */ @Override |
