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: Manual update for get.*_r functions


>>>>> Ulrich Drepper writes:

Uli> Andreas Jaeger <aj@arthur.rhein-neckar.de> writes:
>> I'm appending a patch for the manual to document the POSIX behaviour
>> to summarize my understanding of the issue.

Uli> The test for a NULL pointer should not be necessary.  Where did you
Uli> find this necessary?  It is then a bug in the NSS backend.

I've checked POSIX and my understanding of POSIX is that the check for 
NULL is necessary.

Check the appended test program with the following line in
nsswitch.conf:
hosts:      files dns

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]