On Sun, Feb 18, 2007 at 06:25:30AM +0900, Bram Senders wrote:
> This is easy to patch for ruby 1.9 SVN, see below:

Why allow abstract sockets with UnixServer and UnixSocket, but not with
Socket#sockaddr_un?

Please apply same patch to Socket#sockaddr_un:

Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c (revision 11794)
+++ ext/socket/socket.c (working copy)
@@ -3418,17 +3418,16 @@
 sock_s_pack_sockaddr_un(VALUE self, VALUE path)
 {
     struct sockaddr_un sockaddr;
-    char *sun_path;
     VALUE addr;

     MEMZERO(&sockaddr, struct sockaddr_un, 1);
     sockaddr.sun_family = AF_UNIX;
-    sun_path = StringValueCStr(path);
-    if (sizeof(sockaddr.sun_path) <= strlen(sun_path)) {
+    StringValue(path);
+    if (sizeof(sockaddr.sun_path) <= RSTRING_LEN(path)) {
         rb_raise(rb_eArgError, "too long unix socket path (max: %dbytes)",
             (int)sizeof(sockaddr.sun_path)-1);
     }
-    strncpy(sockaddr.sun_path, sun_path, sizeof(sockaddr.sun_path)-1);
+    memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
     addr = rb_str_new((char*)&sockaddr, sizeof(sockaddr));
     OBJ_INFECT(addr, path);