summaryrefslogtreecommitdiff
path: root/ext/socket/unixsocket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-26 03:34:12 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-26 03:34:12 +0000
commit1413510ed2d8175dcce7c2c14c02e720c8406429 (patch)
treee91eb8fdd906f1ad20e6c0b686229ffff85f3b3b /ext/socket/unixsocket.c
parent2bc4268e7900808b6965176a975c9d392a1239fa (diff)
* ext/socket/raddrinfo.c (init_unix_addrinfo): support the longest
path in sockaddr_un. (inspect_sockaddr): ditto. (addrinfo_mdump): ditto. (addrinfo_mload): ditto. (rsock_unixpath_str): new function. (rsock_unixpath): removed. (rsock_unixaddr): use rsock_unixpath_str. * ext/socket/socket.c (sock_s_pack_sockaddr_un): support the longest path in sockaddr_un. (sock_s_unpack_sockaddr_un): ditto. (sock_s_gethostbyaddr): unused variable removed. * ext/socket/unixsocket.c (rsock_init_unixsock): support the longest path in sockaddr_un. * ext/socket/rubysocket.h (rsock_unixpath_str): declared. (rsock_unixpath): removed. * test/socket/test_unix.rb: comment out test_nul because abstract unix sockets may contain NULs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/unixsocket.c')
-rw-r--r--ext/socket/unixsocket.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c
index 24721fb..596fb5c 100644
--- a/ext/socket/unixsocket.c
+++ b/ext/socket/unixsocket.c
@@ -39,9 +39,9 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server)
MEMZERO(&sockaddr, struct sockaddr_un, 1);
sockaddr.sun_family = AF_UNIX;
- if (sizeof(sockaddr.sun_path) <= (size_t)RSTRING_LEN(path)) {
+ if (sizeof(sockaddr.sun_path) < (size_t)RSTRING_LEN(path)) {
rb_raise(rb_eArgError, "too long unix socket path (%ldbytes given but %dbytes max)",
- RSTRING_LEN(path), (int)sizeof(sockaddr.sun_path)-1);
+ RSTRING_LEN(path), (int)sizeof(sockaddr.sun_path));
}
memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
@@ -118,7 +118,7 @@ unix_path(VALUE sock)
socklen_t len = (socklen_t)sizeof(addr);
if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail(0);
- fptr->pathv = rb_obj_freeze(rb_str_new_cstr(rsock_unixpath(&addr, len)));
+ fptr->pathv = rb_obj_freeze(rsock_unixpath_str(&addr, len));
}
return rb_str_dup(fptr->pathv);
}