Project

General

Profile

Actions

Backport #7786

closed

fix for abstract namespace

Added by shugo (Shugo Maeda) about 11 years ago. Updated about 11 years ago.

Status:
Closed
[ruby-core:51870]

Description

=begin
Please apply the attached patch to Ruby 1.9.3.

In Ruby 1.9.3, the addrlen argument for bind(2) and connect(2) is set to sizeof(struct sockaddr_un).
However, on Linux, if sun_path starts with NUL, which means that the socket's address is in abstract namespace, the first (addrlen - sizeof(sa_family_t)) bytes of sun_path is used as the name of the socket, so the socket name is filled with extra NULs unintentionally. Please see unix(7) for details.

The patch introduces a new function rsock_unix_sockaddr_len() to calculate the correct address length on Linux.

Besides that, the patch includes the following changes.

  • fix Socket.unix_server_socket not to access the file system if the specified name is in abstract namespace.
  • fix rsock_init_unixsock to use rb_inspect() to avoid ArgumentError in rb_sys_fail_str() when path includes NUL.
  • support the longest path in sockaddr_un.
    • This change is necessary for backward compatibility. Without it, the old name filled with extra NULs cannot be specified like UNIXSocket.open(name + "\0" * (108 - name.bytesize)).
      =end

Files

abstract_namespace_fix.diff (20.7 KB) abstract_namespace_fix.diff shugo (Shugo Maeda), 02/05/2013 10:24 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0