[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#724681: eglibc: Bug in sysdeps/mach/hurd/sendmsg.c: patch tg-sendmsg-SCM_RIGHTS.diff



Source: eglibc
Version: 2.17-93
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd

The attached diff (one-liner) to the patch tg-sendmsg-SCM_RIGHTS.diff
fixes the error codes resulting from the HURD_DPORT_USE macro in
connection to the compound statement construct. From
http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Statement-Exprs.html#Statement-Exprs
the following text is found:

"The last thing in the compound statement should be an expression
followed by a semicolon; the value of this subexpression serves as the
value of the entire construct. (If you use some other kind of statement
last within the braces, the construct has type void, and thus
effectively no value.)"

Since the last expression in the compound expression ends with fds[i] =
descriptor->flags; the flags of the descriptor will be returned as err,
not the result of the call to __io_restrict_auth()

Normally, these flags are zero so the return value is zero too, but as
found in one test case for glib2.0, e.g. 36.4-3, gio/tests/socket.c:
/socket/unix-connection-ancillary-data the flag for fds[0] is one. On
Hurd, the error code for one is EKERN_INVALID_ADDRESS, resulting in a
fail instead of a success!

(It looks like passing of file desciptor flags via fds[i] is
non-functional, to be verified, that would require a change of the
patch for both sendmsg.c and recvmsg.c)
--- ../tg-sendmsg-SCM_RIGHTS.diff.old	2012-07-26 08:14:15.000000000 +0200
+++ ../tg-sendmsg-SCM_RIGHTS.diff	2013-09-26 13:07:23.000000000 +0200
@@ -165,7 +165,7 @@ Subject: [PATCH] Add support to send fil
    int i;
  
    /* Find the total number of bytes to be written.  */
-@@ -100,6 +105,46 @@
+@@ -100,6 +105,45 @@
  	}
      }
  
@@ -199,8 +199,7 @@ Subject: [PATCH] Add support to send fil
 +					     0, 0, 0, 0);
 +		   if (! err)
 +		     nports++;
-+		   /* We pass the flags in the control data.  */
-+		   fds[i] = descriptor->flags;
++		   err;
 +		 }));
 +
 +	      if (err)
@@ -212,7 +211,7 @@ Subject: [PATCH] Add support to send fil
    if (addr)
      {
        if (addr->sun_family == AF_LOCAL)
-@@ -109,9 +154,8 @@
+@@ -109,9 +153,8 @@
  	  file_t file = __file_name_lookup (addr->sun_path, 0, 0);
  	  if (file == MACH_PORT_NULL)
  	    {
@@ -224,7 +223,7 @@ Subject: [PATCH] Add support to send fil
  	    }
  	  err = __ifsock_getsockaddr (file, &aport);
  	  __mach_port_deallocate (__mach_task_self (), file);
-@@ -119,11 +163,7 @@
+@@ -119,11 +162,7 @@
  	    /* The file did not grok the ifsock protocol.  */
  	    err = ENOTSOCK;
  	  if (err)
@@ -237,7 +236,7 @@ Subject: [PATCH] Add support to send fil
  	}
        else
  	err = EIEIO;
-@@ -142,8 +182,9 @@
+@@ -142,8 +181,9 @@
  			      /* Send the data.  */
  			      err = __socket_send (port, aport,
  						   flags, data.ptr, len,
@@ -249,7 +248,7 @@ Subject: [PATCH] Add support to send fil
  						   message->msg_control,
  						   message->msg_controllen,
  						   &amount);
-@@ -152,11 +193,19 @@
+@@ -152,11 +192,19 @@
  			    }
  			  err;
  			}));

Reply to: