summary refs log tree commit diff
path: root/library/std/src/sys/path
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-09-04 15:07:06 +0000
committerbors <bors@rust-lang.org>2024-09-04 15:07:06 +0000
commiteeb90cda1969383f56a2637cbd3037bdf598841c (patch)
tree54fd52367088ebbf0c73f13e278d8047fb723aba /library/std/src/sys/path
parentf54dd915b0a4345ee06fd561416ad1af08b54dbb (diff)
parentb666f820546ad2fd15b591acc8dfd7e7f461147e (diff)
downloadrust-1.81.0.tar.gz
rust-1.81.0.zip
Auto merge of #129960 - pietroalbini:pa-cve-2024-43402, r=pietroalbini 1.81.0
[stable] Fix CVE-2024-43402

Backport the fix for CVE-2024-43402 in the upcoming 1.81.0. See https://github.com/rust-lang/rust/security/advisories/GHSA-2xg3-7mm6-98jj for more information about it.

This also includes https://github.com/rust-lang/rust/pull/129944 as a last-minute fix to the relnotes.

cc `@boxyuwu` as you are driving this release
r? `@ghost`
Diffstat (limited to 'library/std/src/sys/path')
-rw-r--r--library/std/src/sys/path/windows.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/sys/path/windows.rs b/library/std/src/sys/path/windows.rs
index cebc7910231..abba705b64f 100644
--- a/library/std/src/sys/path/windows.rs
+++ b/library/std/src/sys/path/windows.rs
@@ -2,6 +2,7 @@ use crate::ffi::{OsStr, OsString};
 use crate::io;
 use crate::path::{Path, PathBuf, Prefix};
 use crate::ptr;
+use crate::sys::api::utf16;
 use crate::sys::pal::{c, fill_utf16_buf, os2path, to_u16s};
 
 #[cfg(test)]
@@ -20,6 +21,10 @@ pub fn is_verbatim_sep(b: u8) -> bool {
     b == b'\\'
 }
 
+pub fn is_verbatim(path: &[u16]) -> bool {
+    path.starts_with(utf16!(r"\\?\")) || path.starts_with(utf16!(r"\??\"))
+}
+
 /// Returns true if `path` looks like a lone filename.
 pub(crate) fn is_file_name(path: &OsStr) -> bool {
     !path.as_encoded_bytes().iter().copied().any(is_sep_byte)