[Top][All Lists]

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

unfilled path in getsockname() for unix sockets

From: Pino Toscano
Subject: unfilled path in getsockname() for unix sockets
Date: Sun, 4 Dec 2011 13:14:52 +0100
User-agent: KMail/1.13.7 (Linux/3.1.0-1-amd64; KDE/4.6.5; x86_64; ; )


while debugging, I apparently stumbled upon a bug of getsockname() for a 
bound unix socket, as also the attached test program shows: sun_path is 
left unfilled, as also the comment of S_socket_whatis_address() in 
hurd/pflocal/pf.c would suggest.

There's also another possibly weird behaviour in that: 
S_socket_whatis_address() sets its sockaddr_len parameter in what seems 
also what Linux does, ie
  offsetof(struct sockaddr, sa_data) + strlen(sun_path) + 1
instead of sizeof(struct sockaddr_un), like apparently most of other 
OSes do[1]; of course, given that sun_path is never filled (as said 
above), the returned sockaddr_len is always 3.

[1] in perl's code, I've seen this snippet:
#   ifndef __linux__
        /* On Linux sockaddrlen on sockets returned by accept, recvfrom,
           getpeername and getsockname is not equal to sizeof(addr). */
        if (sockaddrlen != sizeof(addr)) {
            croak("Bad arg length for %s, length is %d, should be %d",
                        sockaddrlen, sizeof(addr));
#   endif

Pino Toscano

Attachment: sn.c
Description: Text Data

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

reply via email to

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