You've already forked cpp-httplib
Fix UB by use of dangling references in getaddrinfo_with_timeout (#2232)
* Fix use of dangling references When the resolve thread is detached, local variables were still used, which could lead to a program crash. * Add test to verify dangling ref fix * Add missing brace initialization * Assert that the remaining fields are really zeroed * Fix use of chrono literals
This commit is contained in:
committed by
GitHub
parent
f72b4582e6
commit
6e52d0a057
21
test/test.cc
21
test/test.cc
@@ -1331,6 +1331,27 @@ TEST(RangeTest, FromHTTPBin_Online) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GetAddrInfoDanglingRefTest, LongTimeout) {
|
||||
auto host = "unresolvableaddress.local";
|
||||
auto path = std::string{"/"};
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
auto port = 443;
|
||||
SSLClient cli(host, port);
|
||||
#else
|
||||
auto port = 80;
|
||||
Client cli(host, port);
|
||||
#endif
|
||||
cli.set_connection_timeout(1);
|
||||
|
||||
{
|
||||
auto res = cli.Get(path);
|
||||
ASSERT_FALSE(res);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::seconds(8));
|
||||
}
|
||||
|
||||
TEST(ConnectionErrorTest, InvalidHost) {
|
||||
auto host = "-abcde.com";
|
||||
|
||||
|
Reference in New Issue
Block a user