Skip to content

Commit 0f0315b

Browse files
committed
Reference TOCTOU of std::fs in std::path
Signed-off-by: xizheyin <[email protected]>
1 parent ccb55d4 commit 0f0315b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/std/src/path.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,7 +3090,7 @@ impl Path {
30903090
/// Returns `true` if the path points at an existing entity.
30913091
///
30923092
/// Warning: this method may be error-prone, consider using [`try_exists()`] instead!
3093-
/// It also has a risk of introducing time-of-check to time-of-use (TOCTOU) bugs.
3093+
/// It also has a risk of introducing time-of-check to time-of-use ([TOCTOU]) bugs.
30943094
///
30953095
/// This function will traverse symbolic links to query information about the
30963096
/// destination file.
@@ -3111,6 +3111,7 @@ impl Path {
31113111
/// check errors, call [`Path::try_exists`].
31123112
///
31133113
/// [`try_exists()`]: Self::try_exists
3114+
/// [TOCTOU]: fs#time-of-check-to-time-of-use-toctou
31143115
#[stable(feature = "path_ext", since = "1.5.0")]
31153116
#[must_use]
31163117
#[inline]
@@ -3130,7 +3131,7 @@ impl Path {
31303131
/// permission is denied on one of the parent directories.
31313132
///
31323133
/// Note that while this avoids some pitfalls of the `exists()` method, it still can not
3133-
/// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios
3134+
/// prevent time-of-check to time-of-use ([TOCTOU]) bugs. You should only use it in scenarios
31343135
/// where those bugs are not an issue.
31353136
///
31363137
/// This is an alias for [`std::fs::exists`](crate::fs::exists).
@@ -3143,6 +3144,7 @@ impl Path {
31433144
/// assert!(Path::new("/root/secret_file.txt").try_exists().is_err());
31443145
/// ```
31453146
///
3147+
/// [TOCTOU]: fs#time-of-check-to-time-of-use-toctou
31463148
/// [`exists()`]: Self::exists
31473149
#[stable(feature = "path_try_exists", since = "1.63.0")]
31483150
#[inline]

0 commit comments

Comments
 (0)