svn commit: r211276 - head/lib/libc/net

Kostik Belousov kostikbel at gmail.com
Sun Oct 3 18:49:33 UTC 2010


On Fri, Aug 13, 2010 at 06:39:54AM +0000, Hajimu UMEMOTO wrote:
> Author: ume
> Date: Fri Aug 13 06:39:54 2010
> New Revision: 211276
> URL: http://svn.freebsd.org/changeset/base/211276
> 
> Log:
>   - When there is no room for returning the result, nss backend
>     have to return ERANGE and terminate with NS_RETURN.
>   - When gethostbyname_r(3) and the friends end with an error,
>     set errno to the value nss backend returns, and return errno
>     value.
>   
>   PR:		kern/131623
>   MFC after:	2 weeks

I suspect there is some subtle issue with the commit present.
When getprotobyname_r() is unable to find the protocol, it seems
that established behaviour is to return 0 and set *protoent to NULL.

The getprotobyname_r() in HEAD and stable/8, when the protocol
cannot be found, return whatever value was present in errno at the time
of the call.

Below is the example:

#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <strings.h>

int
main(int argc, char *argv[])
{
	char buf[1024];
	struct protoent proto, *pres;
	int res;

	res = getprotobyname_r(argv[1], &proto, buf, sizeof(buf), &pres);
	if (res == 0 && pres != NULL)
		printf("Protocol %s num %d (%p %p)\n", proto.p_name,
		    proto.p_proto, &proto, pres);
	else
		printf("Res %d errno %d %s pres %p\n", res, errno,
		    strerror(errno), pres);
	return (0);
}

When run with the argument "tcp1" on Linux, I get
	Res 0 errno 0 Success pres (nil)
On the recent FreeBSD I get
	Res 25 errno 25 Inappropriate ioctl for device pres 0x0
(ENOTTY is from stdio).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-all/attachments/20101003/f6915cee/attachment.pgp


More information about the svn-src-all mailing list