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

FileOutputStream is able to modify/write to read-only filessince Mustang-b63 (win)

    Details

    • Subcomponent:
    • Introduced In Build:
      b63
    • Introduced In Version:
      6
    • Resolved In Build:
      b69
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Description

      I have a read-only file and I am creating a FileOutputStream out of the read-only file. The FOS modifies the read-only file without any errors and make it '0' byte.

      This is reproducible only on WinXP, only since Mustang-b63. Not reproducible on Mustang-b59c (throws an exception). Not reproducible on Solaris. The file that I have overwritten is not modifiable even by native applications and they say the file is read-only but Java is able to modify it.

      I think this is a regression introduced by the following bug fixed in b63:
      6350200: FileOutputStream.open() throws FileNotFoundException for hidden file (win)

      This is a serious regression in Mustang-RC and java is not supposed to modify read-only files. Needs to be fixed ASAP.

      I have attached a sample test and a sample image. Save them in the same directory. Change the cup.png file to read-only (typically r--r--r--). Run the application and pass the file name as argument. You will see that the file is getting modified and becomes a '0' byte file after creation of FOS even though File.canWrite() returns false.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jhangalsunw Jayalaxmi Hangal (Inactive)
                Reporter:
                pmohansunw Praveen Mohan (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: