mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 13:05:18 +03:00
add gnu_get_libc_version stub for getaddrinfo error path
This commit is contained in:
@@ -246,6 +246,17 @@ fn emulate_foreign_item_inner(
|
||||
this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
"gnu_get_libc_version"
|
||||
if this.frame_in_std()
|
||||
&& this.tcx.sess.target.env == rustc_target::spec::Env::Gnu =>
|
||||
{
|
||||
let [] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
|
||||
// We have to be at least version 2.26 so that std does not call `res_init`.
|
||||
// This returns a C string, so we have to add a null terminator.
|
||||
let version = "2.26\0";
|
||||
let version = this.allocate_str_dedup(version)?;
|
||||
this.write_pointer(version.ptr(), dest)?;
|
||||
}
|
||||
|
||||
_ => return interp_ok(EmulateItemResult::NotSupported),
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//@ignore-target: windows # No socket address support on Windows
|
||||
//@compile-flags: -Zmiri-disable-isolation
|
||||
//@normalize-stderr-test: "address resolution failed: .*" -> "address resolution failed: $$MSG"
|
||||
|
||||
use std::net::{
|
||||
IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, TcpListener, ToSocketAddrs,
|
||||
@@ -29,5 +30,9 @@ fn test_address_resolution() {
|
||||
}
|
||||
}
|
||||
// We expect an IPv4 and an IPv6 address.
|
||||
assert!(addr_count == 2)
|
||||
assert!(addr_count == 2);
|
||||
|
||||
// Resolving an invalid name should error. Needs the port to even hit `getaddrinfo`.
|
||||
let addr_str = "this-is-not-a-valid-address:80";
|
||||
addr_str.to_socket_addrs().unwrap_err();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
warning: address resolution failed: $MSG
|
||||
--> RUSTLIB/std/src/sys/net/PLATFORM/socket/mod.rs:LL:CC
|
||||
|
|
||||
LL | cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints, &mut res))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error during address resolution
|
||||
|
|
||||
= note: Miri cannot return proper error information from this call; only a generic error code is being returned
|
||||
= note: stack backtrace:
|
||||
0: std::sys::net::PLATFORM::socket::lookup_host::{closure#0}
|
||||
at RUSTLIB/std/src/sys/net/PLATFORM/socket/mod.rs:LL:CC
|
||||
1: std::sys::helpers::small_c_string::run_with_cstr_stack::<std::sys::net::PLATFORM::socket::LookupHost>
|
||||
at RUSTLIB/std/src/sys/helpers/small_c_string.rs:LL:CC
|
||||
2: std::sys::helpers::small_c_string::run_with_cstr::<std::sys::net::PLATFORM::socket::LookupHost>
|
||||
at RUSTLIB/std/src/sys/helpers/small_c_string.rs:LL:CC
|
||||
3: std::sys::net::PLATFORM::socket::lookup_host
|
||||
at RUSTLIB/std/src/sys/net/PLATFORM/socket/mod.rs:LL:CC
|
||||
4: std::sys::net::PLATFORM::lookup_host_string
|
||||
at RUSTLIB/std/src/sys/net/PLATFORM/mod.rs:LL:CC
|
||||
5: <str as std::net::ToSocketAddrs>::to_socket_addrs
|
||||
at RUSTLIB/std/src/net/socket_addr.rs:LL:CC
|
||||
6: test_address_resolution
|
||||
at tests/pass/shims/socket-address.rs:LL:CC
|
||||
7: main
|
||||
at tests/pass/shims/socket-address.rs:LL:CC
|
||||
|
||||
Reference in New Issue
Block a user