kern/142717: getsockname / getpeername broken
Stefan Buehler
freebsd at stbuehler.de
Mon Jan 11 13:40:01 UTC 2010
>Number: 142717
>Category: kern
>Synopsis: getsockname / getpeername broken
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Jan 11 13:40:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Stefan Buehler
>Release: 7.2, 8.0
>Organization:
>Environment:
>Description:
I'm not using freebsd myself, but i got a bug report and had a look at the source.
What i want to do is:
socklen_t l = 0;
static struct sockaddr sa;
if (-1 == getsockname(fd, &sa, &l)) {
return NULL;
}
struct sockaddr* saddr = malloc(l);
getsockname(fd, saddr, &l);
return saddr;
The posix manpage clearly states that getsockname stores the length of the address in l and that the data is truncated. The freebsd implementation truncates the data, but it also stores the truncated length.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list