bug-hurd
[Top][All Lists]
Advanced

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

Re: connect() access bytes after socket address


From: Tanaka Akira
Subject: Re: connect() access bytes after socket address
Date: Thu, 28 Feb 2013 15:35:07 +0900

2013/2/28 Roland McGrath <roland@hack.frob.com>:
> I agree they should be consistent.  Note that sendto and sendmsg are
> consistent with connect, rather than with bind.

I didn't know that.
But I still think that the bind() behavior is better.

Giving the length without NUL is traditional practice in applications.
Changing bind() may cause application problems.

4.3BSD document explains as follows.

doc/ps1/08.ipc/2.t of
http://www.tuhs.org/Archive/4BSD/Distributions/4.3BSD/usr.tar.gz :
|
|      #include <sys/un.h>
|       ...
|      struct sockaddr_un addr;
|       ...
|      strcpy(addr.sun_path, "/tmp/foo");
|      addr.sun_family = AF_UNIX;
|      bind(s, (struct sockaddr *) &addr, strlen(addr.sun_path) +
|          sizeof (addr.sun_family));
|
| Note  that  in determining the size of a UNIX domain address
| null bytes are not counted, which is why strlen is used.

4.4BSD document also describes similar.
"An Advanced 4.4BSD Interprocess Communication Tutorial"
http://docs.freebsd.org/44doc/psd/21.ipc/paper.pdf

sizeof (addr.sun_len) is added for 4.4BSD but the description
about null bytes is not changed.

POSIX is different, though.
-- 
Tanaka Akira



reply via email to

[Prev in Thread] Current Thread [Next in Thread]