about summary refs log tree commit diff
path: root/nscd
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-04-02 18:24:52 +0000
committerUlrich Drepper <drepper@redhat.com>2006-04-02 18:24:52 +0000
commite7397b8473c8ebb49d0eabafe07cc15bf15f7944 (patch)
tree8ff8a1995bea828f163c35dba339621b12e1cd67 /nscd
parent6c7a57538a284d495e42c9e89e6a3248b41708ce (diff)
downloadglibc-e7397b8473c8ebb49d0eabafe07cc15bf15f7944.tar.gz
glibc-e7397b8473c8ebb49d0eabafe07cc15bf15f7944.tar.xz
glibc-e7397b8473c8ebb49d0eabafe07cc15bf15f7944.zip
[BZ #2501]
	* nscd/nscd_helper.c (get_mapping): Rewrite code to send request
	so it uses send and not writev.
Diffstat (limited to 'nscd')
-rw-r--r--nscd/nscd_helper.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
index 8025168a5e..fd749446be 100644
--- a/nscd/nscd_helper.c
+++ b/nscd/nscd_helper.c
@@ -176,35 +176,40 @@ get_mapping (request_type type, const char *key,
   struct mapped_database *result = NO_MAPPING;
 #ifdef SCM_RIGHTS
   const size_t keylen = strlen (key) + 1;
-  char resdata[keylen];
   int saved_errno = errno;
 
   int mapfd = -1;
 
   /* Send the request.  */
-  struct iovec iov[2];
-  request_header req;
+  struct
+  {
+    request_header req;
+    char key[keylen];
+  } reqdata;
 
   int sock = open_socket ();
   if (sock < 0)
     goto out;
 
-  req.version = NSCD_VERSION;
-  req.type = type;
-  req.key_len = keylen;
-
-  iov[0].iov_base = &req;
-  iov[0].iov_len = sizeof (req);
-  iov[1].iov_base = (void *) key;
-  iov[1].iov_len = keylen;
+  reqdata.req.version = NSCD_VERSION;
+  reqdata.req.type = type;
+  reqdata.req.key_len = keylen;
+  memcpy (reqdata.key, key, keylen);
 
-  if (__builtin_expect (TEMP_FAILURE_RETRY (__writev (sock, iov, 2))
-			!= iov[0].iov_len + iov[1].iov_len, 0))
+# ifndef MSG_NOSIGNAL
+#  define MSG_NOSIGNAL 0
+# endif
+  if (__builtin_expect (TEMP_FAILURE_RETRY (__send (sock, &reqdata,
+						    sizeof (reqdata),
+						    MSG_NOSIGNAL))
+			!= sizeof (reqdata), 0))
     /* We cannot even write the request.  */
     goto out_close2;
 
   /* Room for the data sent along with the file descriptor.  We expect
      the key name back.  */
+# define resdata reqdata.key
+  struct iovec iov[1];
   iov[0].iov_base = resdata;
   iov[0].iov_len = keylen;
 
@@ -231,11 +236,7 @@ get_mapping (request_type type, const char *key,
   if (wait_on_socket (sock) <= 0)
     goto out_close2;
 
-# ifndef MSG_NOSIGNAL
-#  define MSG_NOSIGNAL 0
-# endif
-  if (__builtin_expect (TEMP_FAILURE_RETRY (__recvmsg (sock, &msg,
-						       MSG_NOSIGNAL))
+  if (__builtin_expect (TEMP_FAILURE_RETRY (__recvmsg (sock, &msg, 0))
 			!= keylen, 0))
     goto out_close2;