diff options
author | Mike Lockwood <lockwood%android.com@gtempaccount.com> | 2011-04-11 14:55:01 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-04-11 14:55:01 -0700 |
commit | 0ffe483a6a9191fc6da031bbcdbdc50f6f64bdf0 (patch) | |
tree | dec7710c68d4e0bfbd76b2456f208acbcb9c0e7d /adb | |
parent | ee3420bc124613827af474684c3015d12742c70d (diff) | |
parent | e4bcf8305748e8799df9047fb0f6881553dd43b5 (diff) | |
download | system_core-0ffe483a6a9191fc6da031bbcdbdc50f6f64bdf0.zip system_core-0ffe483a6a9191fc6da031bbcdbdc50f6f64bdf0.tar.gz system_core-0ffe483a6a9191fc6da031bbcdbdc50f6f64bdf0.tar.bz2 |
am e4bcf830: am d37e0840: Merge "In serial, skip over port as well if numbers found after colon."
* commit 'e4bcf8305748e8799df9047fb0f6881553dd43b5':
In serial, skip over port as well if numbers found after colon.
Diffstat (limited to 'adb')
-rw-r--r-- | adb/sockets.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/adb/sockets.c b/adb/sockets.c index 43925e4..aa4d5fc 100644 --- a/adb/sockets.c +++ b/adb/sockets.c @@ -569,6 +569,32 @@ unsigned unhex(unsigned char *s, int len) return n; } +/* skip_host_serial return the position in a string + skipping over the 'serial' parameter in the ADB protocol, + where parameter string may be a host:port string containing + the protocol delimiter (colon). */ +char *skip_host_serial(char *service) { + char *first_colon, *serial_end; + + first_colon = strchr(service, ':'); + if (!first_colon) { + /* No colon in service string. */ + return NULL; + } + serial_end = first_colon; + if (isdigit(serial_end[1])) { + serial_end++; + while ((*serial_end) && isdigit(*serial_end)) { + serial_end++; + } + if ((*serial_end) != ':') { + // Something other than numbers was found, reset the end. + serial_end = first_colon; + } + } + return serial_end; +} + static int smart_socket_enqueue(asocket *s, apacket *p) { unsigned len; @@ -624,8 +650,8 @@ static int smart_socket_enqueue(asocket *s, apacket *p) char* serial_end; service += strlen("host-serial:"); - // serial number should follow "host:" - serial_end = strchr(service, ':'); + // serial number should follow "host:" and could be a host:port string. + serial_end = skip_host_serial(service); if (serial_end) { *serial_end = 0; // terminate string serial = service; |