Mercurial > hg > octave-kai > gnulib-hg
changeset 5833:98c5aa5b3a1f
getaddrinfo.c: Don't fail when SOCK_STREAM or SOCK_DGRAM are
specified in ai_socktype. Fix invalid ai_protocol
check. ai_protocol is usually set to 0 or depending on
ai_family/ai_socktype to IPPROTO_TCP / IPPROTO_UDP. Checking for
SOCK_STREAM / SOCK_DGRAM in ai_protocol was invalid. Set
ai_socktype / ai_protocol in the returned addrinfo structure.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Tue, 10 May 2005 12:34:54 +0000 |
parents | 23fa52025e8d |
children | 33b72e480067 |
files | lib/ChangeLog lib/getaddrinfo.c |
diffstat | 2 files changed, 16 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,12 @@ +2005-05-10 Yoann Vandoorselaere <yoann.v@prelude-ids.com> + + * getaddrinfo.c: Don't fail when SOCK_STREAM or SOCK_DGRAM are + specified in ai_socktype. Fix invalid ai_protocol + check. ai_protocol is usually set to 0 or depending on + ai_family/ai_socktype to IPPROTO_TCP / IPPROTO_UDP. Checking for + SOCK_STREAM / SOCK_DGRAM in ai_protocol was invalid. Set + ai_socktype / ai_protocol in the returned addrinfo structure. + 2005-05-09 Yoann Vandoorselaere <yoann.v@prelude-ids.com> Bruno Haible <bruno@clisp.org>
--- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -1,5 +1,5 @@ /* Get address information (partial implementation). - Copyright (C) 1997, 2001, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1997, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. Contributed by Simon Josefsson <simon@josefsson.org>. This program is free software; you can redistribute it and/or modify @@ -74,14 +74,10 @@ if (hints && !validate_family (hints->ai_family)) return EAI_FAMILY; - if (hints && hints->ai_socktype) - /* FIXME: Support more socket types. */ - return EAI_SOCKTYPE; - if (hints && - hints->ai_protocol != SOCK_STREAM && hints->ai_protocol != SOCK_DGRAM) - /* FIXME: Support other protocols. */ - return EAI_SERVICE; /* FIXME: Better return code? */ + hints->ai_socktype != SOCK_STREAM && hints->ai_socktype != SOCK_DGRAM) + /* FIXME: Support other socktype. */ + return EAI_SOCKTYPE; /* FIXME: Better return code? */ if (!nodename) /* FIXME: Support server bind mode. */ @@ -90,7 +86,7 @@ if (servname) { const char *proto = - (hints && hints->ai_protocol == SOCK_DGRAM) ? "udp" : "tcp"; + (hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp"; /* FIXME: Use getservbyname_r if available. */ se = getservbyname (servname, proto); @@ -171,6 +167,8 @@ return EAI_NODATA; } + tmp->ai_protocol = (hints) ? hints->ai_protocol : 0; + tmp->ai_socktype = (hints) ? hints->ai_socktype : 0; tmp->ai_addr->sa_family = he->h_addrtype; /* FIXME: If more than one address, create linked list of addrinfo's. */