Bug#192876: libc6: getaddrinfo() does not detect invalid numeric services

2003-05-11 Thread Martin Pool
I suppose it might be argued that it is not getaddrinfo()'s job to
detect illegal invalid ports.  

I'm not sure this stands up: the function is documented as being a
single step to get from a host and/or service name to a (set of)
addresses that can be used to connect.  If this checking is not done
here, then where should it be done?  And what possible purpose could
there be for allowing an invalid port into the result?

--
Martin




Bug#192876: libc6: getaddrinfo() does not detect invalid numeric services

2003-05-10 Thread Martin Pool
Package: libc6
Version: 2.3.1-16
Severity: normal

By my reading of the getaddrinfo() manual (and also the Solaris
manpage) getaddrinfo() ought to return EAI_SERVICE when the requested
service is not available.  However, it does not seem to do this when
the service is a number, but out of the valid range 1-65535 for TCP
ports.

Here is a reproduction case:

--
#include string.h
#include stdio.h
#include stdlib.h

#include sys/types.h
#include sys/socket.h
#include netdb.h

/* try getaddrinfo */
int main(void)
{
int err;
struct addrinfo *res;
struct addrinfo hints;

bzero(hints, sizeof hints);
hints.ai_family = AF_INET; 
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;

err = getaddrinfo(NULL, 8, hints, res);
printf(err=%d, %s\n, err, gai_strerror(err));

return 0;
}
--

On my machine this returns 0, rather than the expected -8 servname
not supported.

If I change 8 to an invalid non-numeric string then the error
is flagged as expected.


-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux wistful 2.4.20 #24 Mon Dec 30 19:32:14 EST 2002 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages libc6 depends on:
ii  libdb1-compat 2.1.3-7The Berkeley database routines [gl

-- no debconf information

--
Martin