Skip to content

Commit

Permalink
Fix crash reported in #30 by SeanKim777 and doomedraven
Browse files Browse the repository at this point in the history
  • Loading branch information
spender-sandbox committed Mar 14, 2017
1 parent 49e56c3 commit 375b154
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions hook_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,30 @@ static PVOID alloc_combined_wsabuf(LPWSABUF buf, DWORD count, DWORD *outlen)
return retbuf;
}

static void get_ip_port(const struct sockaddr *addr,
static BOOLEAN get_ip_port(const struct sockaddr *addr,
char *ip, int *port)
{
lasterror_t lasterror;
BOOLEAN ret = TRUE;

if (addr == NULL)
return;
return FALSE;

get_lasterrors(&lasterror);

// TODO IPv6 support.
if(addr->sa_family == AF_INET) {
const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr;
addr_to_string(addr4->sin_addr, ip);
*port = our_htons(addr4->sin_port);
}

__try {
// TODO IPv6 support.
if (addr->sa_family == AF_INET) {
const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr;
addr_to_string(addr4->sin_addr, ip);
*port = our_htons(addr4->sin_port);
}
}
__except (EXCEPTION_EXECUTE_HANDLER) {
ret = FALSE;
}
set_lasterrors(&lasterror);
return ret;
}

HOOKDEF(int, WINAPI, WSAStartup,
Expand Down

0 comments on commit 375b154

Please sign in to comment.