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 network/19445] New: getaddrinfo clears errno


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

            Bug ID: 19445
           Summary: getaddrinfo clears errno
           Product: glibc
           Version: 2.23
            Status: NEW
          Severity: normal
          Priority: P2
         Component: network
          Assignee: unassigned at sourceware dot org
          Reporter: msebor at redhat dot com
  Target Milestone: ---

In subsection 2.3 of the General Information section of the Base Definitions
volume, POSIX specifies that

  No function in this volume of POSIX.1-2008 shall set errno to zero.

Based on the requirement, the following test case sets errno to a non-zero
value and expects it to remain non-zero after a successful call to
getaddrinfo().  The test fails with the latest glibc.

$ (cd /build/glibc-trunk/resolv && env GCONV_PATH=/build/glibc-trunk/iconvdata
LOCPATH=/build/glibc-trunk/localedata LC_ALL=C  
/build/glibc-trunk/elf/ld64.so.2 --library-path
/build/glibc-trunk:/build/glibc-trunk/math:/build/glibc-trunk/elf:/build/glibc-trunk/dlfcn:/build/glibc-trunk/nss:/build/glibc-trunk/nis:/build/glibc-trunk/rt:/build/glibc-trunk/resolv:/build/glibc-trunk/crypt:/build/glibc-trunk/mathvec:/build/glibc-trunk/nptl
/build/glibc-trunk/resolv/tst-getaddrinfo-errno)
errno = 0 (Success)
tst-getaddrinfo-errno: tst-getaddrinfo-errno.c:23: main: Assertion `err != 0'
failed.

#include <assert.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>

int main (void)
{
    struct addrinfo* result;

    errno = 123;

    int s = getaddrinfo ("gcc.gnu.org", NULL, NULL, &result);

    int err = errno;

    if (s) {
        fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
        return 1;
    }

    printf ("errno = %i (%s)\n", err, strerror (err));
    assert (err != 0); 

    freeaddrinfo (result);
    return 0;
}

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