This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: A new glibc bug



Appended is a small test program that shows the problem.  The output
is (with current glibc cvs 2.1.2):

$ ./gethst_r-test 
gethostbyname_r returned: 0
herr: 1
hp is null

But shouldn't gethostbyname_r return a nonzero value?

Andreas

#include <netdb.h>
#include <stdio.h>
#include <alloca.h>

int
main (void)
{
  struct hostent hostbuf, *hp;
  size_t hstbuflen;
  char *tmphstbuf;
  int res;
  int herr;
  
  hstbuflen = 1024;
  tmphstbuf = alloca (hstbuflen);

  res = gethostbyname_r ("unknownhost", &hostbuf, tmphstbuf, hstbuflen, &hp, &herr);

  printf ("gethostbyname_r returned: %d\n", res);
  printf ("herr: %d\n", herr);
  printf ("hp is %s\n", hp == NULL ? "null" : "set");

  return res;
}

-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de

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