This is the mail archive of the libc-alpha@sources.redhat.com 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]

gethostbyname_r problem in glibc-2.2.93


Aloha,

The following change causes the return value of gethostbyname_r to
disagree with the glibc documentation:

2002-08-25  Ulrich Drepper  <drepper@redhat.com>

	* nss/getXXbyYY_r.c (REENTRANT_NAME): Return ENOENT if status is
	neither SUCCESS nor TRYAGAIN [PR libc/4259].

===================================================================
RCS file: /cvs/glibc/libc/nss/getXXbyYY_r.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- libc/nss/getXXbyYY_r.c	2002/08/03 06:25:51	1.42
+++ libc/nss/getXXbyYY_r.c	2002/08/26 06:15:30	1.43
@@ -229,7 +229,8 @@
 #ifdef POSTPROCESS
   POSTPROCESS;
 #endif
-  return status == NSS_STATUS_SUCCESS ? 0 : errno;
+  return (status == NSS_STATUS_SUCCESS
+	  ? 0 : (status == NSS_STATUS_TRYAGAIN ? EAGAIN : ENOENT));
 }
 
 
According to the documentation:

     If the function [gethostbyname_r] failed the return value is an error
     number.  In addition to the errors defined for `gethostbyname' it
     can also be `ERANGE'.  In this case the call should be repeated
     with a larger buffer.

Currently, gethostbyname_r returns EAGAIN instead of ERANGE and breaks
compatibility w/ glibc-2.2.5.  I've attached a slightly modified version of
the example code from the documentation which fails because ERANGE
is not returned (tested on alpha-pc-linux-gnu and i586-pc-linux-gnu).

- glen

Attachment: gethostname.c
Description: Text document


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