This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH,HURD] sendto: do not crash when addr is NULL


currently, sendto() crashes when the specified addr is NULL; the 
attached patch fixes it making sendto() with NULL addr behave as it 
would be a plain send().

Pino Toscano
Hurd: sendto: do not crash when addr is NULL

Work also when the specified addr is NULL; simplify also the usage of err.

2012-05-20  Pino Toscano  <>

	* sysdeps/mach/hurd/sendto.c: Consider also when addr is NULL.
--- a/sysdeps/mach/hurd/sendto.c
+++ b/sysdeps/mach/hurd/sendto.c
@@ -33,11 +33,11 @@ __sendto (int fd,
 	  const struct sockaddr_un *addr,
 	  socklen_t addr_len)
-  addr_port_t aport;
-  error_t err;
+  addr_port_t aport = MACH_PORT_NULL;
+  error_t err = 0;
   size_t wrote;
-  if (addr->sun_family == AF_LOCAL)
+  if (addr != NULL && addr->sun_family == AF_LOCAL)
       /* For the local domain, we must look up the name as a file and talk
 	 to it with the ifsock protocol.  */
@@ -52,13 +52,11 @@ __sendto (int fd,
       if (err)
 	return __hurd_fail (err);
-  else
-    err = EIEIO;
   /* Get an address port for the desired destination address.  */
   err = HURD_DPORT_USE (fd,
-			  if (err)
+			  if (aport == MACH_PORT_NULL && addr != NULL)
 			    err = __socket_create_address (port,
 							   (char *) addr,

Attachment: signature.asc
Description: This is a digitally signed message part.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]