about summary refs log tree commit diff
path: root/nscd
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-02-02 16:27:57 +0000
committerUlrich Drepper <drepper@redhat.com>1999-02-02 16:27:57 +0000
commit813f4f4dff904de333642ffa8c17b9309d8f182e (patch)
treeb4b2174e80fa05212e0e1bc91d9abda4b94306dc /nscd
parentb1418d8f39dd2b26fd67c3350493431f99514285 (diff)
downloadglibc-813f4f4dff904de333642ffa8c17b9309d8f182e.tar.gz
glibc-813f4f4dff904de333642ffa8c17b9309d8f182e.tar.xz
glibc-813f4f4dff904de333642ffa8c17b9309d8f182e.zip
Update.
	* nscd/nscd_getpw_r.c (nscd_getpw_r): Mark as internal and take
	extra argument with length of key string.
	(__nscd_getpwnam_r): Call nscd_getpw_r with extra argument.
	(__nscd_getpwuid_r): Create key string on stack.
	* nscd/nscd_getgr_r.c: Mark local functions as internal.
	* nscd/nscd_gethst_r.c: Likewise.
Diffstat (limited to 'nscd')
-rw-r--r--nscd/nscd_getgr_r.c3
-rw-r--r--nscd/nscd_gethst_r.c3
-rw-r--r--nscd/nscd_getpw_r.c32
3 files changed, 18 insertions, 20 deletions
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index eb9d280eee..7d2caac088 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -35,7 +35,7 @@ int __nss_not_use_nscd_group;
 
 static int nscd_getgr_r (const char *key, size_t keylen, request_type type,
 			 struct group *resultbuf, char *buffer,
-			 size_t buflen);
+			 size_t buflen) internal_function;
 
 
 int
@@ -89,6 +89,7 @@ open_socket (void)
 
 
 static int
+internal_function
 nscd_getgr_r (const char *key, size_t keylen, request_type type,
 	      struct group *resultbuf, char *buffer, size_t buflen)
 {
diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c
index e8d9ef2495..46f1611c63 100644
--- a/nscd/nscd_gethst_r.c
+++ b/nscd/nscd_gethst_r.c
@@ -37,7 +37,7 @@ int __nss_not_use_nscd_hosts;
 
 static int nscd_gethst_r (const char *key, size_t keylen, request_type type,
 			  struct hostent *resultbuf, char *buffer,
-			  size_t buflen, int *h_errnop);
+			  size_t buflen, int *h_errnop) internal_function;
 
 
 int
@@ -114,6 +114,7 @@ open_socket (void)
 
 
 static int
+internal_function
 nscd_gethst_r (const char *key, size_t keylen, request_type type,
 	       struct hostent *resultbuf, char *buffer, size_t buflen,
 	       int *h_errnop)
diff --git a/nscd/nscd_getpw_r.c b/nscd/nscd_getpw_r.c
index 3cfe558862..5050253bd2 100644
--- a/nscd/nscd_getpw_r.c
+++ b/nscd/nscd_getpw_r.c
@@ -33,9 +33,9 @@
 
 int __nss_not_use_nscd_passwd;
 
-static int nscd_getpw_r (const char *key, request_type type,
+static int nscd_getpw_r (const char *key, size_t keylen, request_type type,
 			 struct passwd *resultbuf, char *buffer,
-			 size_t buflen);
+			 size_t buflen) internal_function;
 
 int
 __nscd_getpwnam_r (const char *name, struct passwd *resultbuf, char *buffer,
@@ -44,25 +44,20 @@ __nscd_getpwnam_r (const char *name, struct passwd *resultbuf, char *buffer,
   if (name == NULL)
     return 1;
 
-  return nscd_getpw_r (name, GETPWBYNAME, resultbuf, buffer, buflen);
+  return nscd_getpw_r (name, strlen (name) + 1, GETPWBYNAME, resultbuf,
+		       buffer, buflen);
 }
 
 int
 __nscd_getpwuid_r (uid_t uid, struct passwd *resultbuf, char *buffer,
 		   size_t buflen)
 {
-  char *p = buffer;
-  int plen;
+  char buf[12];
+  size_t n;
 
-  plen = __snprintf (buffer, buflen, "%d", uid);
-  if (plen == -1)
-    {
-      __set_errno (ERANGE);
-      return -1;
-    }
-  p = buffer + plen + 1;
+  n = __snprintf (buf, sizeof (buf), "%d", uid) + 1;
 
-  return nscd_getpw_r (buffer, GETPWBYUID, resultbuf, p, buflen - plen - 1);
+  return nscd_getpw_r (buf, n, GETPWBYUID, resultbuf, buffer, buflen);
 }
 
 /* Create a socket connected to a name. */
@@ -93,8 +88,9 @@ open_socket (void)
 }
 
 static int
-nscd_getpw_r (const char *key, request_type type, struct passwd *resultbuf,
-	      char *buffer, size_t buflen)
+internal_function
+nscd_getpw_r (const char *key, size_t keylen, request_type type,
+	      struct passwd *resultbuf, char *buffer, size_t buflen)
 {
   int sock = open_socket ();
   request_header req;
@@ -109,7 +105,7 @@ nscd_getpw_r (const char *key, request_type type, struct passwd *resultbuf,
 
   req.version = NSCD_VERSION;
   req.type = type;
-  req.key_len = strlen (key) + 1;
+  req.key_len = keylen;
   nbytes = __write (sock, &req, sizeof (request_header));
   if (nbytes != sizeof (request_header))
     {
@@ -117,8 +113,8 @@ nscd_getpw_r (const char *key, request_type type, struct passwd *resultbuf,
       return 1;
     }
 
-  nbytes = __write (sock, key, req.key_len);
-  if (nbytes != req.key_len)
+  nbytes = __write (sock, key, keylen);
+  if (nbytes != keylen)
     {
       __close (sock);
       return 1;