RFR: 8073061: (fs) Files.copy(foo, bar, REPLACE_EXISTING) deletes bar even if foo is not readable [v2]

Brian Burkhalter bpb at openjdk.org
Tue Sep 5 16:57:39 UTC 2023


On Tue, 5 Sep 2023 06:53:13 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8073061: Check file system access only for move; add move sub-test
>
> src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java line 920:
> 
>> 918:                 // Ensure source can be moved
>> 919:                 try {
>> 920:                     access(source, W_OK);
> 
> Are you sure W_OK is correct and not R_OK or R_OK|W_OK ?

After all I think `R_OK|W_OK` would cover both the atomic and non-atomic (copy + delete) cases.

> src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java line 1050:
> 
>> 1048:             else if (!sourceAttrs.isSymbolicLink() || flags.followLinks)
>> 1049:                 // Ensure source can be read
>> 1050:                 provider.checkAccess(source, AccessMode.READ);
> 
> I think access(source, R_OK) would be better here, otherwise the additional SM check is observable.

An oversight; thanks.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15501#discussion_r1316153651
PR Review Comment: https://git.openjdk.org/jdk/pull/15501#discussion_r1316154013


More information about the nio-dev mailing list