summaryrefslogtreecommitdiffstats
path: root/adb/jdwp_service.cpp
diff options
context:
space:
mode:
authorErik Kline <ek@google.com>2015-12-01 17:27:59 +0900
committerErik Kline <ek@google.com>2015-12-07 16:07:46 +0900
commit7e16cc15b5e16ec35f4c9f0516a6cacf90326856 (patch)
treeac9676eac446d951c7a0726f9b2ec24c3e96fe1c /adb/jdwp_service.cpp
parent1462c78c9cb1b4ee8d6b68b33fa7be64d6b9fbd4 (diff)
downloadsystem_core-7e16cc15b5e16ec35f4c9f0516a6cacf90326856.tar.gz
system_core-7e16cc15b5e16ec35f4c9f0516a6cacf90326856.tar.bz2
system_core-7e16cc15b5e16ec35f4c9f0516a6cacf90326856.zip
Switch from using sockaddr to sockaddr_storage.
This is to ensure sufficient space is always available. Change-Id: Ifa87b93ecdc90dcacbfb24446c872344da6703d3
Diffstat (limited to 'adb/jdwp_service.cpp')
-rw-r--r--adb/jdwp_service.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/adb/jdwp_service.cpp b/adb/jdwp_service.cpp
index cc2d44e08..3c812cce7 100644
--- a/adb/jdwp_service.cpp
+++ b/adb/jdwp_service.cpp
@@ -460,11 +460,11 @@ jdwp_control_init( JdwpControl* control,
const char* sockname,
int socknamelen )
{
- struct sockaddr_un addr;
- socklen_t addrlen;
- int s;
- int maxpath = sizeof(addr.sun_path);
- int pathlen = socknamelen;
+ sockaddr_un addr;
+ socklen_t addrlen;
+ int s;
+ int maxpath = sizeof(addr.sun_path);
+ int pathlen = socknamelen;
if (pathlen >= maxpath) {
D( "vm debug control socket name too long (%d extra chars)",
@@ -485,7 +485,7 @@ jdwp_control_init( JdwpControl* control,
addrlen = (pathlen + sizeof(addr.sun_family));
- if (bind(s, (struct sockaddr*)&addr, addrlen) < 0) {
+ if (bind(s, reinterpret_cast<sockaddr*>(&addr), addrlen) < 0) {
D( "could not bind vm debug control socket: %d: %s",
errno, strerror(errno) );
adb_close(s);
@@ -523,13 +523,14 @@ jdwp_control_event( int s, unsigned events, void* _control )
JdwpControl* control = (JdwpControl*) _control;
if (events & FDE_READ) {
- struct sockaddr addr;
- socklen_t addrlen = sizeof(addr);
- int s = -1;
- JdwpProcess* proc;
+ sockaddr_storage ss;
+ sockaddr* addrp = reinterpret_cast<sockaddr*>(&ss);
+ socklen_t addrlen = sizeof(ss);
+ int s = -1;
+ JdwpProcess* proc;
do {
- s = adb_socket_accept( control->listen_socket, &addr, &addrlen );
+ s = adb_socket_accept(control->listen_socket, addrp, &addrlen);
if (s < 0) {
if (errno == EINTR)
continue;