Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Jan 2010 13:39:21 GMT
From:      Stefan Buehler <freebsd@stbuehler.de>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/142717: getsockname / getpeername broken
Message-ID:  <201001111339.o0BDdLMK089922@www.freebsd.org>
Resent-Message-ID: <201001111340.o0BDe1O2070808@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001111339.o0BDdLMK089922>