summaryrefslogtreecommitdiff
path: root/ext/socket/raddrinfo.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-15 22:19:05 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-15 22:19:05 +0000
commitcb31e783798438420e33a84a8bfe66acafaa7c4a (patch)
treeabd633cd3da6ebf4155f883b0179866487235998 /ext/socket/raddrinfo.c
parent84a525bc4e47c33c07cc135e6e77df1369375042 (diff)
* ext/socket/extconf.rb: test struct sockaddr_un and its member,
sun_len. * ext/socket/sockport.h (INIT_SOCKADDR_UN): new macro defined. * ext/socket/socket.c (sock_s_pack_sockaddr_un): use INIT_SOCKADDR_UN. * ext/socket/unixsocket.c (rsock_init_unixsock): ditto. * ext/socket/raddrinfo.c (init_unix_addrinfo): ditto. (addrinfo_mload): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/raddrinfo.c')
-rw-r--r--ext/socket/raddrinfo.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 057287a..cb7c06e 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -797,9 +797,7 @@ init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype)
"too long unix socket path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
(size_t)RSTRING_LEN(path), sizeof(un.sun_path));
- MEMZERO(&un, struct sockaddr_un, 1);
-
- un.sun_family = AF_UNIX;
+ INIT_SOCKADDR_UN(&un, sizeof(struct sockaddr_un));
memcpy((void*)&un.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
len = rsock_unix_sockaddr_len(path);
@@ -1317,8 +1315,7 @@ addrinfo_mload(VALUE self, VALUE ary)
case AF_UNIX:
{
struct sockaddr_un uaddr;
- MEMZERO(&uaddr, struct sockaddr_un, 1);
- uaddr.sun_family = AF_UNIX;
+ INIT_SOCKADDR_UN(&uaddr, sizeof(struct sockaddr_un));
StringValue(v);
if (sizeof(uaddr.sun_path) < (size_t)RSTRING_LEN(v))