]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Correct handling of TRYAGAIN error when buffer is too small.
authorUlrich Drepper <drepper@redhat.com>
Sun, 1 Feb 1998 15:29:47 +0000 (15:29 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 1 Feb 1998 15:29:47 +0000 (15:29 +0000)
nss/getXXbyYY_r.c
nss/getXXent_r.c

index 13a6426dfb55e53f8060c00badf023c46b9c0933..0bd79cba5ec37f907e23f39418995e14f657160b 100644 (file)
@@ -130,13 +130,18 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
   while (no_more == 0)
     {
       status = (*fct) (ADD_VARIABLES, resbuf, buffer, buflen H_ERRNO_VAR);
-      if (status == NSS_STATUS_TRYAGAIN)
-       {
-         /* XXX This is very wrong but there is no fast soluation in sight.
-            Give the previous module a chance to complete it's
-            operation before errno will be reset by the next call */
-         break;
-       }
+
+      /* The the status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
+        provided buffer is too small.  In this case we should give
+        the user the possibility to enlarge the buffer and we should
+        not simply go on with the next service (even if the TRYAGAIN
+        action tells us so).  */
+      if (status == NSS_STATUS_TRYAGAIN
+#ifdef NEED_H_ERRNO
+         && *h_errnop == NETDB_INTERNAL
+#endif
+         && errno == ERANGE)
+       break;
 
       no_more = __nss_next (&nip, REENTRANT_NAME_STRING,
                            (void **) &fct, status, 0);
index b43463b11d83e3f87ca451b37962b4f31b0e8fd7..8dbdba8564311763a41860a2cca26a8084d5aa80 100644 (file)
@@ -245,13 +245,18 @@ INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *resbuf, char *buffer, size_t buflen,
       service_user *current_nip = nip;
 
       status = (*fct) (resbuf, buffer, buflen H_ERRNO_VAR);
-      if (status == NSS_STATUS_TRYAGAIN)
-       {
-         /* XXX This is very wrong but there is no fast solution in sight.
-            Give the previous module a chance to complete it's
-            operation before errno will be reset by the next call */
-         break;
-       }
+
+      /* The the status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
+        provided buffer is too small.  In this case we should give
+        the user the possibility to enlarge the buffer and we should
+        not simply go on with the next service (even if the TRYAGAIN
+        action tells us so).  */
+      if (status == NSS_STATUS_TRYAGAIN
+#ifdef NEED_H_ERRNO
+         && *h_errnop == NETDB_INTERNAL
+#endif
+         && errno == ERANGE)
+       break;
 
       no_more = __nss_next (&nip, GETFUNC_NAME_STRING, (void **) &fct,
                            status, 0);