Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8234479

FilePermission for "<<ALL FILES>>" does not imply an invalid path file.

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      JDK: OpenJDK 8u232


      A DESCRIPTION OF THE PROBLEM :
      * This issue occurred on OpenJDK 8u232
        So I reported here.

      [OpenJDK 8u232]
      -------
      FilePermission allReadWrite = new FilePermission("<<ALL FILES>>", "read,write");
      FilePermission invalidFilePathRead = new FilePermission("C:\\aaa\\bbb:ccc.txt", "read");

      allReadWrite.implies(invalidFilePathRead) ==> false
      -------

      Should it returns true or false?

      [Other versions]
      OpenJDK 8u222 => true
      OpenJDK 11.0.5 => true
      OpenJDK 13.0.1 => true
      Oracle JDK 8u231 => true

      In JDK 9 and later, FilePermission handles "<<ALL FILES>>" specially by the following code.

      -------
          boolean impliesIgnoreMask(FilePermission that) {
              if (this == that) {
                  return true;
              }
              if (allFiles) {
                  return true;
              }
              if (this.invalid || that.invalid) {
                  return false;
              }
      -------


      REGRESSION : Last worked in version 8u231

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javac InvalidFilePathPermission.java
      java InvalidFilePathPermission


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      print "true"
      ACTUAL -
      print "false"

      ---------- BEGIN SOURCE ----------
      InvalidFilePathPermission.java
      -------
      import java.io.File;
      import java.io.FilePermission;

      public class InvalidFilePathPermission {
          public static void main(String[] args) {
              FilePermission allReadWrite = new FilePermission("<<ALL FILES>>", "read,write");
              FilePermission invalidFilePathRead = new FilePermission("C:\\aaa\\bbb:ccc.txt", "read");

              System.out.println(allReadWrite.implies(invalidFilePathRead));
          }
      }
      -------

      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: