Skip to content

Commit 012d349

Browse files
yfeldblumfacebook-github-bot
authored andcommitted
fix nullptr-dereference in SocketAddress
Summary: When `getaddrinfo` fails, `SocketAddress` attempts to describe the error and throw an exception with that description. It includes the content of the `node` or `host` param, which is a C-string, without checking whether the param is nullptr. When `SocketAddress::getAddrInfo` is called with a nullptr param but where its internal call to `getaddrinfo` fails, this triggers a segv crash. Reviewed By: knekritz Differential Revision: D70706294 fbshipit-source-id: 0f4144bcb670c4e8e24dd014c9bc0c4ccad06981
1 parent 387fe3b commit 012d349

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

folly/SocketAddress.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ struct addrinfo* SocketAddress::getAddrInfo(
632632
if (error != 0) {
633633
auto os = fmt::format(
634634
"Failed to resolve address for '{}': {} (error={})",
635-
host,
635+
(host ? host : "<null>"),
636636
GetAddrInfoError(error).str(),
637637
error);
638638
throw std::system_error(error, std::generic_category(), os);

0 commit comments

Comments
 (0)