From 3726a0195b7b9394db080ccad9543431bdd59ef8 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Thu, 30 Mar 2017 13:04:35 -0700 Subject: [PATCH] Revert "adb: check our socketpair ends in our win32 emulation." This reverts commit 5990191c4e4802567881db2f19db4adbddc64e1e. Some Windows users are seeing mismatches between the two ends. Bug: https://code.google.com/p/android/issues/detail?id=258400 Test: mma Change-Id: Ie3a121a2754332608ff64b3b016adcb4258d41f3 --- adb/sysdeps.h | 4 ---- adb/sysdeps_win32.cpp | 29 ++--------------------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/adb/sysdeps.h b/adb/sysdeps.h index f195b4eb4..f95a8556f 100644 --- a/adb/sysdeps.h +++ b/adb/sysdeps.h @@ -268,10 +268,6 @@ extern int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t #undef accept #define accept ___xxx_accept -int adb_getsockname(int fd, struct sockaddr* sockaddr, socklen_t* optlen); -#undef getsockname -#define getsockname(...) ___xxx_getsockname(__VA__ARGS__) - // Returns the local port number of a bound socket, or -1 on failure. int adb_socket_get_local_port(int fd); diff --git a/adb/sysdeps_win32.cpp b/adb/sysdeps_win32.cpp index f997e6b84..5873b2b39 100644 --- a/adb/sysdeps_win32.cpp +++ b/adb/sysdeps_win32.cpp @@ -984,7 +984,7 @@ int adb_getsockname(int fd, struct sockaddr* sockaddr, socklen_t* optlen) { return -1; } - int result = (getsockname)(fh->fh_socket, sockaddr, optlen); + int result = getsockname(fh->fh_socket, sockaddr, optlen); if (result == SOCKET_ERROR) { const DWORD err = WSAGetLastError(); D("adb_getsockname: setsockopt on fd %d failed: %s\n", fd, @@ -1042,11 +1042,6 @@ int adb_socketpair(int sv[2]) { int local_port = -1; std::string error; - struct sockaddr_storage peer_addr = {}; - struct sockaddr_storage client_addr = {}; - socklen_t peer_socklen = sizeof(peer_addr); - socklen_t client_socklen = sizeof(client_addr); - server = network_loopback_server(0, SOCK_STREAM, &error); if (server < 0) { D("adb_socketpair: failed to create server: %s", error.c_str()); @@ -1066,32 +1061,12 @@ int adb_socketpair(int sv[2]) { goto fail; } - // Make sure that the peer that connected to us and the client are the same. - accepted = adb_socket_accept(server, reinterpret_cast(&peer_addr), &peer_socklen); + accepted = adb_socket_accept(server, nullptr, nullptr); if (accepted < 0) { D("adb_socketpair: failed to accept: %s", strerror(errno)); goto fail; } - - if (adb_getsockname(client, reinterpret_cast(&client_addr), &client_socklen) != 0) { - D("adb_socketpair: failed to getpeername: %s", strerror(errno)); - goto fail; - } - - if (peer_socklen != client_socklen) { - D("adb_socketpair: client and peer sockaddrs have different lengths"); - errno = EIO; - goto fail; - } - - if (memcmp(&peer_addr, &client_addr, peer_socklen) != 0) { - D("adb_socketpair: client and peer sockaddrs don't match"); - errno = EIO; - goto fail; - } - adb_close(server); - sv[0] = client; sv[1] = accepted; return 0;