summary refs log tree commit diff
path: root/nscd/nscd_getpw_r.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-01-15 10:52:50 +0000
committerUlrich Drepper <drepper@redhat.com>2003-01-15 10:52:50 +0000
commit9caf4f1c67e137804f4bca9eb65bd0132424022a (patch)
tree33f1aa53ffc08e5aff06a6c7eb6977969febeb51 /nscd/nscd_getpw_r.c
parentc9f24336e0c78fc4722f857902f1bf921b2ca1d1 (diff)
downloadglibc-9caf4f1c67e137804f4bca9eb65bd0132424022a.tar.gz
glibc-9caf4f1c67e137804f4bca9eb65bd0132424022a.tar.xz
glibc-9caf4f1c67e137804f4bca9eb65bd0132424022a.zip
Update.
	* nscd/nscd_getpw_r.c (nscd_getpw_r): Consolidate writing of the
	request with one writev call.  Protect all read calls with
	TEMP_FAILURE_RETRY.
	* nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise.
	* nscd/nscd_gethst_r.c (nscd_gethst_r): Likewise.

	* nscd/hstcache.c: Use extend_alloca to reallocate alloca'd buffer.
	Protect writev calls with TEMP_FAILURE_RETRY.
	* nscd/grpcache.c: Likewise.
	* nscd/pwdcache.c: Likewise.
Diffstat (limited to 'nscd/nscd_getpw_r.c')
-rw-r--r--nscd/nscd_getpw_r.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/nscd/nscd_getpw_r.c b/nscd/nscd_getpw_r.c
index 06f41efe5e..f4fa75fa6f 100644
--- a/nscd/nscd_getpw_r.c
+++ b/nscd/nscd_getpw_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@uni-paderborn.de>, 1998.
 
@@ -96,6 +96,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type,
   request_header req;
   pw_response_header pw_resp;
   ssize_t nbytes;
+  struct iovec vec[2];
 
   if (sock == -1)
     {
@@ -106,21 +107,21 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type,
   req.version = NSCD_VERSION;
   req.type = type;
   req.key_len = keylen;
-  nbytes = __write (sock, &req, sizeof (request_header));
-  if (nbytes != sizeof (request_header))
-    {
-      __close (sock);
-      return -1;
-    }
 
-  nbytes = __write (sock, key, keylen);
-  if (nbytes != keylen)
+  vec[0].iov_base = &req;
+  vec[0].iov_len = sizeof (request_header);
+  vec[1].iov_base = (void *) key;
+  vec[1].iov_len = keylen;
+
+  nbytes = (size_t) TEMP_FAILURE_RETRY (__writev (sock, vec, 2));
+  if (nbytes != sizeof (request_header) + keylen)
     {
       __close (sock);
       return -1;
     }
 
-  nbytes = __read (sock, &pw_resp, sizeof (pw_response_header));
+  nbytes = TEMP_FAILURE_RETRY (__read (sock, &pw_resp,
+				       sizeof (pw_response_header)));
   if (nbytes != sizeof (pw_response_header))
     {
       __close (sock);
@@ -168,7 +169,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type,
       /* get pw_pshell */
       resultbuf->pw_shell = p;
 
-      nbytes = __read (sock, buffer, total);
+      nbytes = TEMP_FAILURE_RETRY (__read (sock, buffer, total));
 
       __close (sock);