aboutsummaryrefslogtreecommitdiff
path: root/socket_test.cpp
diff options
context:
space:
mode:
authorDavid Pursell <dpursell@google.com>2016-09-21 12:08:37 -0700
committerDavid Pursell <dpursell@google.com>2016-09-21 13:00:32 -0700
commit24b62a7e0c29f966c43464862f1d2cbf6575b76e (patch)
treed6405e09e21794b042d737122a7f9338a0c73ed9 /socket_test.cpp
parent54ab20e5bb3b620e4d9b522f2c799dea655b13fc (diff)
downloadadb-24b62a7e0c29f966c43464862f1d2cbf6575b76e.tar.gz
adb: fix host-side serial number parsing for IPv6.
When the adb client sends a command to the adb server targeting a particular device serial, it looks something like this: host-serial:<serial>:<command> But if <serial> happens to be an IPv6 address (e.g. when `adb connect` targets IPv6), the current parsing code doesn't handle the additional colons properly. This CL fixes the host-serial parsing to handle this case. This only affects commands that explicitly name a device serial, e.g.: adb -s <IPv6> shell adb -s <IPv6> forward <port> <port> Implicitly using a single attached device was unaffected by this bug. Bug: http://b/30891386 Test: `adb -s [fe80::ba27:ebff:feb1:934%eth2]:5555 shell` works now, and new unittests pass. Change-Id: Iffe784e61432ae94eb96ed3c8477900a3e807329
Diffstat (limited to 'socket_test.cpp')
-rw-r--r--socket_test.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/socket_test.cpp b/socket_test.cpp
index 2bb01a38..5e79b5e2 100644
--- a/socket_test.cpp
+++ b/socket_test.cpp
@@ -307,6 +307,17 @@ TEST(socket_test, test_skip_host_serial) {
// Don't register a port unless it's all numbers and ends with ':'.
VerifySkipHostSerial(protocol + "foo:123", ":123");
VerifySkipHostSerial(protocol + "foo:123bar:baz", ":123bar:baz");
+
+ VerifySkipHostSerial(protocol + "100.100.100.100:5555:foo", ":foo");
+ VerifySkipHostSerial(protocol + "[0123:4567:89ab:CDEF:0:9:a:f]:5555:foo", ":foo");
+ VerifySkipHostSerial(protocol + "[::1]:5555:foo", ":foo");
+
+ // If we can't find both [] then treat it as a normal serial with [ in it.
+ VerifySkipHostSerial(protocol + "[0123:foo", ":foo");
+
+ // Don't be fooled by random IPv6 addresses in the command string.
+ VerifySkipHostSerial(protocol + "foo:ping [0123:4567:89ab:CDEF:0:9:a:f]:5555",
+ ":ping [0123:4567:89ab:CDEF:0:9:a:f]:5555");
}
}