Try to more safely handle empty hostnames.
Test: as follows
- built
- flashed
- booted
- manual testing in modes: {off, opportunistic, strict}
- system/netd/tests/runtests.sh
Bug: 74606156
Change-Id: I183e5de0ba77571fefd686ac0a9e53e6011722a4
diff --git a/server/ResolverController.cpp b/server/ResolverController.cpp
index a5074e2..24c996d 100644
--- a/server/ResolverController.cpp
+++ b/server/ResolverController.cpp
@@ -134,9 +134,9 @@
netdEventListener = eventReporter.getNetdEventListener();
}
if (netdEventListener != nullptr) {
- netdEventListener->onPrivateDnsValidationEvent(netId,
- String16(addrToString(&(server.ss)).c_str()),
- String16(server.name.c_str()), success);
+ const String16 ipLiteral(addrToString(&(server.ss)).c_str());
+ const String16 hostname(server.name.empty() ? "" : server.name.c_str());
+ netdEventListener->onPrivateDnsValidationEvent(netId, ipLiteral, hostname, success);
if (DBG) {
ALOGD("Sending validation %s event on netId %u for %s with hostname %s",
success ? "success" : "failure", netId,