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 17:05:36 UTC 2023
On Tue, 5 Sep 2023 16:54:48 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> 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.
So changed in e226096d15b47bee7cee20ec2994bca93a071433.
>> 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.
Fixed in e226096d15b47bee7cee20ec2994bca93a071433.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15501#discussion_r1316158992
PR Review Comment: https://git.openjdk.org/jdk/pull/15501#discussion_r1316158385
More information about the nio-dev
mailing list