[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#499781: libc6-dbg: return value of gethostbyname_r() is different from *h_errnop



Package: libc6-dbg
Version: 2.7-13
Severity: normal


In the following code the return value of gethostbyname_r() is 0,
but *h_errno is 3, what violates documentation.

---
struct hostent host;
struct hostent *hostp;
int herr;
char ghbn_buf[1024*1024+1];
int nh;

hostp=&host;
nh=gethostbyname_r(hname,hostp,ghbn_buf,1024*1024,&hostp,&herr);
---

gdb results:

(gdb) display nh
1: nh = 0
(gdb) print herr
$1 = 3
(gdb) print hname
$2 = 0xa18e200 "00000129"
(gdb) print hostp
$3 = (struct hostent *) 0x0
(gdb) print herr
$4 = 3

$1 should be the same as $4 according to the documentation (man
gethostbyname):

Glibc2 also has reentrant versions gethostent_r(),
gethostbyaddr_r(), gethostbyname_r() and gethostbyname2_r(). The caller
supplies a hostent structure ret which will be filled in on success, and
a tempo- rary work buffer buf of size buflen. After the call, result
will point to the result on success. In case of an error or if no entry
is found result will be NULL. The functions return 0 on success and a
non-zero error number on failure. In addition to the errors
returned by the non-reentrant versions of these functions, if buf is too
small, the functions will return ERANGE, and the call should be
retried with a larger buffer. The global variable h_errno is not modified,
but the address of a variable in which to store error numbers is
passed in h_errnop.




-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core)
Locale: LANG=cs_CZ, LC_CTYPE=cs_CZ (charmap=ISO-8859-2)
Shell: /bin/sh linked to /bin/bash

Versions of packages libc6-dbg depends on:
ii  libc6                         2.7-13     GNU C Library: Shared libraries

libc6-dbg recommends no packages.

libc6-dbg suggests no packages.

-- no debconf information



Reply to: