summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index f5ff5694272..9527cf3da11 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1434,6 +1434,8 @@ unix_addr(sock)
if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
+ if (len == 0)
+ addr.sun_path[0] = '\0';
return unixaddr(&addr);
}
@@ -1449,6 +1451,8 @@ unix_peeraddr(sock)
if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
+ if (len == 0)
+ addr.sun_path[0] = '\0';
return unixaddr(&addr);
}
#endif