diff options
| author | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2025-02-13 18:39:52 +0100 |
|---|---|---|
| committer | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2025-02-25 13:43:53 +0100 |
| commit | b899e4b0cda73cca24dc22c8396d72b1cc39dc6c (patch) | |
| tree | ac54e67c63c404f7d30829cc08c332e7ab1fe21c /talpid-windows/src | |
| parent | 0cce552a63620ca316a21ee29abcb9f0ab23cf52 (diff) | |
| download | mullvadvpn-b899e4b0cda73cca24dc22c8396d72b1cc39dc6c.tar.xz mullvadvpn-b899e4b0cda73cca24dc22c8396d72b1cc39dc6c.zip | |
Fix improper pointer provenance
`&mut buffer[0] as *mut u8` will create a raw pointer that is only
allowed to access the very first byte of `buffer`. `slice::as_mut_ptr`
is preferred.
Diffstat (limited to 'talpid-windows/src')
| -rw-r--r-- | talpid-windows/src/net.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/talpid-windows/src/net.rs b/talpid-windows/src/net.rs index a15a2a82db..33c79e1a9d 100644 --- a/talpid-windows/src/net.rs +++ b/talpid-windows/src/net.rs @@ -393,9 +393,7 @@ pub fn luid_from_alias<T: AsRef<OsStr>>(alias: T) -> io::Result<NET_LUID_LH> { /// Returns the alias of an interface given its LUID. pub fn alias_from_luid(luid: &NET_LUID_LH) -> io::Result<OsString> { let mut buffer = [0u16; IF_MAX_STRING_SIZE as usize + 1]; - win32_err!(unsafe { - ConvertInterfaceLuidToAlias(luid, &mut buffer[0] as *mut _, buffer.len()) - })?; + win32_err!(unsafe { ConvertInterfaceLuidToAlias(luid, buffer.as_mut_ptr(), buffer.len()) })?; let nul = buffer.iter().position(|&c| c == 0u16).unwrap(); Ok(OsString::from_wide(&buffer[0..nul])) } |
