mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
2bc4268e79
commit
1413510ed2
6 changed files with 65 additions and 52 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue