This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/16208] New: getaddrinfo() does not detect invalid numeric services


https://sourceware.org/bugzilla/show_bug.cgi?id=16208

            Bug ID: 16208
           Summary: getaddrinfo() does not detect invalid numeric services
           Product: glibc
           Version: 2.17
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: shawnlandden at gmail dot com
                CC: drepper.fsp at gmail dot com

forwarded from Debian bug 192876

From: Martin Pool <mbp@sourcefrog.net>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: libc6: getaddrinfo() does not detect invalid numeric services
Date: Sun, 11 May 2003 13:00:17 +1000

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, "80000", &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 "80000" to an invalid non-numeric string then the error
is flagged as expected.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]