[EventEngine] Returns error instead of assertion when hostname is empty (#35306)
<!--
If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.
If your pull request is for a specific language, please add the appropriate
lang label.
-->
Closes #35306
COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35306 from yijiem:dns-empty-hostname 9c7f67c27a
PiperOrigin-RevId: 591028370
This commit is contained in:
parent
b455726401
commit
90cdff5a3c
|
|
@ -241,7 +241,13 @@ void AresResolver::LookupHostname(
|
|||
"Unparseable name: ", name))]() mutable { callback(status); });
|
||||
return;
|
||||
}
|
||||
GPR_ASSERT(!host.empty());
|
||||
if (host.empty()) {
|
||||
event_engine_->Run([callback = std::move(callback),
|
||||
status = absl::InvalidArgumentError(absl::StrCat(
|
||||
"host must not be empty in name: ",
|
||||
name))]() mutable { callback(status); });
|
||||
return;
|
||||
}
|
||||
if (port_string.empty()) {
|
||||
if (default_port.empty()) {
|
||||
event_engine_->Run([callback = std::move(callback),
|
||||
|
|
@ -307,7 +313,13 @@ void AresResolver::LookupSRV(
|
|||
"Unparseable name: ", name))]() mutable { callback(status); });
|
||||
return;
|
||||
}
|
||||
GPR_ASSERT(!host.empty());
|
||||
if (host.empty()) {
|
||||
event_engine_->Run([callback = std::move(callback),
|
||||
status = absl::InvalidArgumentError(absl::StrCat(
|
||||
"host must not be empty in name: ",
|
||||
name))]() mutable { callback(status); });
|
||||
return;
|
||||
}
|
||||
// Don't query for SRV records if the target is "localhost"
|
||||
if (absl::EqualsIgnoreCase(host, "localhost")) {
|
||||
event_engine_->Run([callback = std::move(callback)]() mutable {
|
||||
|
|
@ -336,7 +348,13 @@ void AresResolver::LookupTXT(
|
|||
"Unparseable name: ", name))]() mutable { callback(status); });
|
||||
return;
|
||||
}
|
||||
GPR_ASSERT(!host.empty());
|
||||
if (host.empty()) {
|
||||
event_engine_->Run([callback = std::move(callback),
|
||||
status = absl::InvalidArgumentError(absl::StrCat(
|
||||
"host must not be empty in name: ",
|
||||
name))]() mutable { callback(status); });
|
||||
return;
|
||||
}
|
||||
// Don't query for TXT records if the target is "localhost"
|
||||
if (absl::EqualsIgnoreCase(host, "localhost")) {
|
||||
event_engine_->Run([callback = std::move(callback)]() mutable {
|
||||
|
|
|
|||
|
|
@ -591,4 +591,9 @@ TEST_F(EventEngineDNSTest, UnparseableHostPortsBadLocalhostWithPort) {
|
|||
TestUnparseableHostPort(CreateDNSResolverWithoutSpecifyingServer(),
|
||||
&dns_resolver_signal_, "[localhost]:1");
|
||||
}
|
||||
|
||||
TEST_F(EventEngineDNSTest, UnparseableHostPortsEmptyHostname) {
|
||||
TestUnparseableHostPort(CreateDNSResolverWithoutSpecifyingServer(),
|
||||
&dns_resolver_signal_, ":443");
|
||||
}
|
||||
// END
|
||||
|
|
|
|||
Loading…
Reference in New Issue