Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
net_uv: use sufficient buffer to read sock/peername
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Sep 9, 2011
1 parent 85357ab commit f810998
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tcp_wrap.cc
Expand Up @@ -121,7 +121,7 @@ class TCPWrap : public StreamWrap {

static Handle<Value> GetSockName(const Arguments& args) {
HandleScope scope;
struct sockaddr address;
struct sockaddr_storage address;
int family;
int port;
char ip[INET6_ADDRSTRLEN];
Expand All @@ -137,7 +137,7 @@ class TCPWrap : public StreamWrap {
if (r != 0) {
SetErrno(uv_last_error(uv_default_loop()).code);
} else {
family = address.sa_family;
family = address.ss_family;
if (family == AF_INET) {
struct sockaddr_in* addrin = (struct sockaddr_in*)&address;
uv_inet_ntop(AF_INET, &(addrin->sin_addr), ip, INET6_ADDRSTRLEN);
Expand All @@ -159,7 +159,7 @@ class TCPWrap : public StreamWrap {

static Handle<Value> GetPeerName(const Arguments& args) {
HandleScope scope;
struct sockaddr address;
struct sockaddr_storage address;
int family;
int port;
char ip[INET6_ADDRSTRLEN];
Expand All @@ -175,7 +175,7 @@ class TCPWrap : public StreamWrap {
if (r != 0) {
SetErrno(uv_last_error(uv_default_loop()).code);
} else {
family = address.sa_family;
family = address.ss_family;
if (family == AF_INET) {
struct sockaddr_in* addrin = (struct sockaddr_in*)&address;
uv_inet_ntop(AF_INET, &(addrin->sin_addr), ip, INET6_ADDRSTRLEN);
Expand Down

0 comments on commit f810998

Please sign in to comment.