about summary refs log tree commit diff
path: root/nss
diff options
context:
space:
mode:
Diffstat (limited to 'nss')
-rw-r--r--nss/getXXbyYY.c17
-rw-r--r--nss/getXXbyYY_r.c11
-rw-r--r--nss/getXXent.c15
-rw-r--r--nss/getXXent_r.c11
-rw-r--r--nss/nss_db/db-netgrp.c2
5 files changed, 35 insertions, 21 deletions
diff --git a/nss/getXXbyYY.c b/nss/getXXbyYY.c
index a99b68f0e2..c300117b8c 100644
--- a/nss/getXXbyYY.c
+++ b/nss/getXXbyYY.c
@@ -60,16 +60,21 @@ Boston, MA 02111-1307, USA.  */
 
 
 /* Prototype for reentrant version we use here.  */
-extern LOOKUP_TYPE *INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *result,
-					       char *buffer, int buflen
-					       H_ERRNO_PARM);
+extern int INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf,
+				      char *buffer, size_t buflen,
+				      LOOKUP_TYPE **result H_ERRNO_PARM);
 
 LOOKUP_TYPE *
 FUNCTION_NAME (ADD_PARAMS)
 {
-  static LOOKUP_TYPE result;
   static char buffer[BUFLEN];
+  static LOOKUP_TYPE resbuf;
+  LOOKUP_TYPE *result;
 
-  return INTERNAL (REENTRANT_NAME) (ADD_VARIABLES, &result, buffer,
-				    BUFLEN H_ERRNO_VAR);
+  if (INTERNAL (REENTRANT_NAME) (ADD_VARIABLES, &resbuf, buffer,
+				 BUFLEN, &result H_ERRNO_VAR) != 0)
+    /* Error occured.  */
+    return NULL;
+
+  return result;
 }
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index 631fd1e33e..d85169ab81 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -82,9 +82,9 @@ extern int DB_LOOKUP_FCT (service_user **nip, const char *name, void **fctp);
 
 
 
-LOOKUP_TYPE *
-INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *result, char *buffer,
-			   int buflen H_ERRNO_PARM)
+int
+INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
+			   size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM)
 {
   static service_user *startp = NULL;
   static lookup_function start_fct;
@@ -122,13 +122,14 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *result, char *buffer,
 
   while (no_more == 0)
     {
-      status = (*fct) (ADD_VARIABLES, result, buffer, buflen H_ERRNO_VAR);
+      status = (*fct) (ADD_VARIABLES, resbuf, buffer, buflen H_ERRNO_VAR);
 
       no_more = __nss_next (&nip, REENTRANT_NAME_STRING,
 			    (void **) &fct, status, 0);
     }
 
-  return status == NSS_STATUS_SUCCESS ? result : NULL;
+  *result = status == NSS_STATUS_SUCCESS ? resbuf : NULL;
+  return status == NSS_STATUS_SUCCESS ? 0 : -1;
 }
 
 #define do_weak_alias(n1, n2) weak_alias ((n1), (n2))
diff --git a/nss/getXXent.c b/nss/getXXent.c
index ecf7eadc4c..7e291e6298 100644
--- a/nss/getXXent.c
+++ b/nss/getXXent.c
@@ -51,15 +51,22 @@ Boston, MA 02111-1307, USA.  */
 #endif
 
 /* Prototype of the reentrant version.  */
-LOOKUP_TYPE *INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *result, char *buffer,
-					   int buflen H_ERRNO_PARM);
+extern int INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *resbuf, char *buffer,
+					 size_t buflen, LOOKUP_TYPE **result
+					 H_ERRNO_PARM);
 
 
 LOOKUP_TYPE *
 GETFUNC_NAME (void)
 {
   static char buffer[BUFLEN];
-  static LOOKUP_TYPE result;
+  static LOOKUP_TYPE resbuf;
+  LOOKUP_TYPE *result;
 
-  return INTERNAL (REENTRANT_GETNAME) (&result, buffer, BUFLEN H_ERRNO_VAR);
+  if (INTERNAL (REENTRANT_GETNAME) (&resbuf, buffer, BUFLEN, &result
+				    H_ERRNO_VAR) != 0)
+    /* Errors occured.  */
+    return NULL;
+
+  return result;
 }
diff --git a/nss/getXXent_r.c b/nss/getXXent_r.c
index 6bff863e07..1d06a9477a 100644
--- a/nss/getXXent_r.c
+++ b/nss/getXXent_r.c
@@ -187,9 +187,9 @@ ENDFUNC_NAME (void)
 }
 
 
-LOOKUP_TYPE *
-INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *result, char *buffer, int buflen
-			      H_ERRNO_PARM)
+int
+INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *resbuf, char *buffer, size_t buflen,
+			      LOOKUP_TYPE **result H_ERRNO_PARM)
 {
   get_function fct;
   int no_more;
@@ -214,7 +214,7 @@ INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *result, char *buffer, int buflen
   no_more = setup ((void **) &fct, GETFUNC_NAME_STRING, 0);
   while (! no_more)
     {
-      status = (*fct) (result, buffer, buflen H_ERRNO_VAR);
+      status = (*fct) (resbuf, buffer, buflen H_ERRNO_VAR);
 
       no_more = __nss_next (&nip, GETFUNC_NAME_STRING, (void **) &fct,
 			    status, 0);
@@ -222,7 +222,8 @@ INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *result, char *buffer, int buflen
 
   __libc_lock_unlock (lock);
 
-  return status == NSS_STATUS_SUCCESS ? result : NULL;
+  *result = NSS_STATUS_SUCCESS ? resbuf : NULL;
+  return status == NSS_STATUS_SUCCESS ? 0 : -1;
 }
 #define do_weak_alias(n1, n2) weak_alias (n1, n2)
 do_weak_alias (INTERNAL (REENTRANT_GETNAME), REENTRANT_GETNAME)
diff --git a/nss/nss_db/db-netgrp.c b/nss/nss_db/db-netgrp.c
index 3afede56c6..2090dd1eff 100644
--- a/nss/nss_db/db-netgrp.c
+++ b/nss/nss_db/db-netgrp.c
@@ -52,7 +52,7 @@ _nss_db_setnetgrent (const char *group)
       db = dbopen (DBFILE, O_RDONLY, 0, DB_BTREE, NULL);
 
       if (db == NULL)
-	status = errno = EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
+	status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
     }
 
   if (status == NSS_STATUS_SUCCESS)