[前][次][番号順一覧][スレッド一覧]

ruby-changes:50794

From: nobu <ko1@a...>
Date: Wed, 28 Mar 2018 20:30:33 +0900 (JST)
Subject: [ruby-changes:50794] nobu:r63000 (trunk): unixsocket.c: abstract namespace

nobu	2018-03-28 20:30:27 +0900 (Wed, 28 Mar 2018)

  New Revision: 63000

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63000

  Log:
    unixsocket.c: abstract namespace
    
    * ext/socket/unixsocket.c (unixsock_path_value): fix r62991 for
      Linux abstract namespace.

  Modified files:
    trunk/ext/socket/unixsocket.c
Index: ext/socket/unixsocket.c
===================================================================
--- ext/socket/unixsocket.c	(revision 62999)
+++ ext/socket/unixsocket.c	(revision 63000)
@@ -25,6 +25,28 @@ unixsock_connect_internal(VALUE a) https://github.com/ruby/ruby/blob/trunk/ext/socket/unixsocket.c#L25
 			        arg->sockaddrlen, 0);
 }
 
+static VALUE
+unixsock_path_value(VALUE path)
+{
+#ifdef __linux__
+#define TO_STR_FOR_LINUX_ABSTRACT_NAMESPACE 0
+
+    VALUE name = path;
+#if TO_STR_FOR_LINUX_ABSTRACT_NAMESPACE
+    const int isstr = !NIL_P(name = rb_check_string_type(name));
+#else
+    const int isstr = RB_TYPE_P(name, T_STRING);
+#endif
+    if (isstr) {
+        if (RSTRING_LEN(name) == 0 || RSTRING_PTR(name)[0] == '\0') {
+            rb_check_safe_obj(name);
+            return name;             /* ignore encoding */
+        }
+    }
+#endif
+    return rb_get_path(path);
+}
+
 VALUE
 rsock_init_unixsock(VALUE sock, VALUE path, int server)
 {
@@ -33,7 +55,7 @@ rsock_init_unixsock(VALUE sock, VALUE pa https://github.com/ruby/ruby/blob/trunk/ext/socket/unixsocket.c#L55
     int fd, status;
     rb_io_t *fptr;
 
-    FilePathValue(path);
+    path = unixsock_path_value(path);
 
     INIT_SOCKADDR_UN(&sockaddr, sizeof(struct sockaddr_un));
     if (sizeof(sockaddr.sun_path) < (size_t)RSTRING_LEN(path)) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]