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

[PATCH][BZ #15014] Return ERANGE if buffer size is not large enough for digits_dots


Hi,
    
__nss_hostname_digits_dots returns an ERANGE when the buffer size is
not large enough.  However, the combination of errno, NSS status and
h_errno are not correct.  The h_errno should be NETDB_INTERNAL and
status should be NSS_STATUS_TRYAGAIN.  Finally, we adjust checks in
getXXXbyYYY_r.c so that we conclude that we didn't use any services
only if status is NSS_STATUS_UNAVAIL.  This allows
__nss_hostname_digits_dots to set NSS_STATUS_TRYAGAIN.

No regressions in the testsuite (using xcheck) on x86_64.  OK to
commit?

Siddhesh

	[BZ #15014]
	* nss/digits_dots.c (__nss_hostname_digits_dots): Set correct
	H_ERRNOP and STATUS on insufficient buffer size.
	* nss/getXXbyYY_r.c (REENTRANT_NAME): Adjust check for failure
	due to not being able to use any service.

diff --git a/nss/digits_dots.c b/nss/digits_dots.c
index 2b86295..ad75b6e 100644
--- a/nss/digits_dots.c
+++ b/nss/digits_dots.c
@@ -90,8 +90,9 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
 	  if (buflen < size_needed)
 	    {
 	      if (h_errnop != NULL)
-		*h_errnop = TRY_AGAIN;
+		*h_errnop = NETDB_INTERNAL;
 	      __set_errno (ERANGE);
+	      *status = NSS_STATUS_TRYAGAIN;
 	      goto done;
 	    }
 	}
@@ -239,8 +240,9 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
 	  if (buffer_size == NULL && buflen < size_needed)
 	    {
 	      if (h_errnop != NULL)
-		*h_errnop = TRY_AGAIN;
+		*h_errnop = NETDB_INTERNAL;
 	      __set_errno (ERANGE);
+	      *status = NSS_STATUS_TRYAGAIN;
 	      goto done;
 	    }
 	  else if (buffer_size != NULL && *buffer_size < size_needed)
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index 1067744..8c7e2c3 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -289,7 +289,7 @@ done:
        had a system error.  Set NETDB_INTERNAL here to let the caller know
        that the errno may have the real reason for failure.  */
       *h_errnop = NETDB_INTERNAL;
-  else if (status != NSS_STATUS_SUCCESS && !any_service)
+  else if (status == NSS_STATUS_UNAVAIL && !any_service)
     /* We were not able to use any service.  */
     *h_errnop = NO_RECOVERY;
 #endif


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