adbd: strip nulls from all service strings.
Other services are checking for exact equality, like jdwp.
Test: adb jdwp
Change-Id: I1081904621b111b0143a275bd9337f903fe9c111
diff --git a/adb/adb.cpp b/adb/adb.cpp
index fdf720c..06e4c50 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -359,6 +359,11 @@
if (t->online && p->msg.arg0 != 0 && p->msg.arg1 == 0) {
std::string_view address(p->payload.begin(), p->payload.size());
+ // Historically, we received service names as a char*, and stopped at the first NUL
+ // byte. The client sent strings with null termination, which post-string_view, start
+ // being interpreted as part of the string, unless we explicitly strip them.
+ address = StripTrailingNulls(address);
+
asocket* s = create_local_service_socket(address, t);
if (s == nullptr) {
send_close(0, p->msg.arg0, t);