Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #111153

Merged
merged 31 commits into from
May 3, 2023
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e40a446
Support loading version information from xz tarballs
Mark-Simulacrum Apr 17, 2023
20742ea
Adjust obligation cause code for find_and_report_unsatisfied_index_impl
compiler-errors Apr 26, 2023
25e9b79
interpret: fail more gracefully on uninit unsized locals
RalfJung Apr 27, 2023
6fcf165
move some const-prop tests to appropriate folder
RalfJung Apr 28, 2023
b4ba2f0
Change rlink serialization from `MemEncoder` to `FileEncoder`.
nnethercote May 1, 2023
0453cda
Don't bail out early when checking invalid `repr` attr
clubby789 May 1, 2023
bc68de9
remove pointless `FIXME` in `bootstrap::download`
onur-ozkan May 1, 2023
8d359e4
Move some `Encodable`/`Decodable` tests.
nnethercote May 2, 2023
ebee3f8
Remove `MemEncoder`.
nnethercote May 1, 2023
ef77dd2
resolve: One more attempt to simplify `module_children`
petrochenkov Apr 27, 2023
7bc6d59
Avoid ICEing miri on layout query cycles
oli-obk May 2, 2023
6af761a
Add some triagebot notifications for nnethercote.
nnethercote May 2, 2023
51b9f78
Amend the triagebot comment for `Cargo.lock` changes.
nnethercote May 2, 2023
6e01e91
Implement negative bounds
compiler-errors Apr 25, 2023
86f50b9
Disallow associated type constraints on negative bounds
compiler-errors Apr 25, 2023
40a63cb
Make tools happy
compiler-errors Apr 25, 2023
03469c3
Make negative trait bounds work with the old trait solver
compiler-errors Apr 25, 2023
6fca051
Rustfmt support for negative bounds, test
compiler-errors Apr 26, 2023
6e37784
Correctly convert an NT path to a Win32 path
ChrisDenton Feb 12, 2023
109a47f
Use `from_wide_to_user_path` in `read_link`
ChrisDenton May 3, 2023
068807a
Rollup merge of #107978 - ChrisDenton:nt-to-win32, r=m-ou-se
Dylan-DPC May 3, 2023
32f3ddb
Rollup merge of #110436 - Mark-Simulacrum:support-xz-version, r=pietr…
Dylan-DPC May 3, 2023
80df4ab
Rollup merge of #110791 - compiler-errors:negative-bounds, r=oli-obk
Dylan-DPC May 3, 2023
a2e4dab
Rollup merge of #110874 - compiler-errors:index-op-specific, r=oli-obk
Dylan-DPC May 3, 2023
0228994
Rollup merge of #110908 - petrochenkov:notagain4, r=compiler-errors
Dylan-DPC May 3, 2023
8b7080b
Rollup merge of #110943 - RalfJung:interpret-unsized-arg-ice, r=oli-obk
Dylan-DPC May 3, 2023
fce0741
Rollup merge of #111062 - clubby789:invalid-repr-unchecked, r=petroch…
Dylan-DPC May 3, 2023
a47fa34
Rollup merge of #111069 - ozkanonur:remove-pointless-fixme, r=albertl…
Dylan-DPC May 3, 2023
887dffc
Rollup merge of #111086 - nnethercote:rm-MemEncoder, r=cjgillot
Dylan-DPC May 3, 2023
e87fcf9
Rollup merge of #111097 - oli-obk:🚲_layout, r=compiler-errors
Dylan-DPC May 3, 2023
b5bbe68
Rollup merge of #111112 - nnethercote:triagebot, r=compiler-errors
Dylan-DPC May 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Correctly convert an NT path to a Win32 path
This can be done by simply changing the `\??\` prefix to `\\?\` and then attempting to convert to a user path.

Currently it simply strips off the prefix which could lead to the wrong path being returned (e.g. if it's not a drive path or if the path contains trailing spaces, etc).
ChrisDenton committed May 3, 2023

Verified

This commit was signed with the committer’s verified signature.
ChrisDenton Chris Denton
commit 6e377849c09a310b6eef50ebd91c1f014d41ab73
6 changes: 5 additions & 1 deletion library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
@@ -919,6 +919,7 @@ fn symlink_noexist() {

#[test]
fn read_link() {
let tmpdir = tmpdir();
if cfg!(windows) {
// directory symlink
assert_eq!(check!(fs::read_link(r"C:\Users\All Users")), Path::new(r"C:\ProgramData"));
@@ -933,8 +934,11 @@ fn read_link() {
Path::new(r"C:\Users")
);
}
// Check that readlink works with non-drive paths on Windows.
let link = tmpdir.join("link_unc");
check!(symlink_dir(r"\\localhost\c$\", &link));
assert_eq!(check!(fs::read_link(&link)), Path::new(r"\\localhost\c$\"));
}
let tmpdir = tmpdir();
let link = tmpdir.join("link");
if !got_symlink_permission(&tmpdir) {
return;
27 changes: 16 additions & 11 deletions library/std/src/sys/windows/fs.rs
Original file line number Diff line number Diff line change
@@ -477,7 +477,7 @@ impl File {
fn reparse_point(
&self,
space: &mut Align8<[MaybeUninit<u8>]>,
) -> io::Result<(c::DWORD, *const c::REPARSE_DATA_BUFFER)> {
) -> io::Result<(c::DWORD, *mut c::REPARSE_DATA_BUFFER)> {
unsafe {
let mut bytes = 0;
cvt({
@@ -496,7 +496,7 @@ impl File {
)
})?;
const _: () = assert!(core::mem::align_of::<c::REPARSE_DATA_BUFFER>() <= 8);
Ok((bytes, space.0.as_ptr().cast::<c::REPARSE_DATA_BUFFER>()))
Ok((bytes, space.0.as_mut_ptr().cast::<c::REPARSE_DATA_BUFFER>()))
}
}

@@ -506,22 +506,22 @@ impl File {
unsafe {
let (path_buffer, subst_off, subst_len, relative) = match (*buf).ReparseTag {
c::IO_REPARSE_TAG_SYMLINK => {
let info: *const c::SYMBOLIC_LINK_REPARSE_BUFFER =
ptr::addr_of!((*buf).rest).cast();
let info: *mut c::SYMBOLIC_LINK_REPARSE_BUFFER =
ptr::addr_of_mut!((*buf).rest).cast();
assert!(info.is_aligned());
(
ptr::addr_of!((*info).PathBuffer).cast::<u16>(),
ptr::addr_of_mut!((*info).PathBuffer).cast::<u16>(),
(*info).SubstituteNameOffset / 2,
(*info).SubstituteNameLength / 2,
(*info).Flags & c::SYMLINK_FLAG_RELATIVE != 0,
)
}
c::IO_REPARSE_TAG_MOUNT_POINT => {
let info: *const c::MOUNT_POINT_REPARSE_BUFFER =
ptr::addr_of!((*buf).rest).cast();
let info: *mut c::MOUNT_POINT_REPARSE_BUFFER =
ptr::addr_of_mut!((*buf).rest).cast();
assert!(info.is_aligned());
(
ptr::addr_of!((*info).PathBuffer).cast::<u16>(),
ptr::addr_of_mut!((*info).PathBuffer).cast::<u16>(),
(*info).SubstituteNameOffset / 2,
(*info).SubstituteNameLength / 2,
false,
@@ -535,13 +535,18 @@ impl File {
}
};
let subst_ptr = path_buffer.add(subst_off.into());
let mut subst = slice::from_raw_parts(subst_ptr, subst_len as usize);
let subst = slice::from_raw_parts_mut(subst_ptr, subst_len as usize);
// Absolute paths start with an NT internal namespace prefix `\??\`
// We should not let it leak through.
if !relative && subst.starts_with(&[92u16, 63u16, 63u16, 92u16]) {
subst = &subst[4..];
// Turn `\??\` into `\\?\` (a verbatim path).
subst[1] = b'\\' as u16;
// Attempt to convert to a more user-friendly path.
let user = super::args::to_user_path(subst.iter().copied().chain([0]).collect())?;
Ok(PathBuf::from(OsString::from_wide(&user)))
} else {
Ok(PathBuf::from(OsString::from_wide(subst)))
}
Ok(PathBuf::from(OsString::from_wide(subst)))
}
}