diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-02-21 11:15:54 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-02-21 11:15:54 +0000 |
commit | b428b742cf54d423e5a7a68fcbec9473303eeafa (patch) | |
tree | a7eb4bb9273b2c48c1d4deacb5458f5075d902ef /nscd | |
parent | 6c8cc2d3042d0585741452006c29cb21fbba39ea (diff) | |
download | glibc-b428b742cf54d423e5a7a68fcbec9473303eeafa.tar glibc-b428b742cf54d423e5a7a68fcbec9473303eeafa.tar.gz glibc-b428b742cf54d423e5a7a68fcbec9473303eeafa.tar.bz2 glibc-b428b742cf54d423e5a7a68fcbec9473303eeafa.zip |
Updated to fedora-glibc-20070221T1011cvs/fedora-glibc-2_5_90-18
Diffstat (limited to 'nscd')
-rw-r--r-- | nscd/grpcache.c | 1 | ||||
-rw-r--r-- | nscd/hstcache.c | 4 | ||||
-rw-r--r-- | nscd/nscd.c | 36 | ||||
-rw-r--r-- | nscd/nscd_helper.c | 5 | ||||
-rw-r--r-- | nscd/pwdcache.c | 1 | ||||
-rw-r--r-- | nscd/servicescache.c | 4 |
6 files changed, 29 insertions, 22 deletions
diff --git a/nscd/grpcache.c b/nscd/grpcache.c index 54d1ef1eef..3852e8ca7f 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -279,6 +279,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, /* Adjust pointers into the memory block. */ gr_name = (char *) newp + (gr_name - (char *) dataset); cp = (char *) newp + (cp - (char *) dataset); + key_copy = (char *) newp + (key_copy - (char *) dataset); dataset = memcpy (newp, dataset, total + n); alloca_used = false; diff --git a/nscd/hstcache.c b/nscd/hstcache.c index 742491aea3..ad2e323eac 100644 --- a/nscd/hstcache.c +++ b/nscd/hstcache.c @@ -311,8 +311,8 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, /* Adjust pointers into the memory block. */ addresses = (char *) newp + (addresses - (char *) dataset); aliases = (char *) newp + (aliases - (char *) dataset); - if (key_copy != NULL) - key_copy = (char *) newp + (key_copy - (char *) dataset); + assert (key_copy != NULL); + key_copy = (char *) newp + (key_copy - (char *) dataset); dataset = memcpy (newp, dataset, total + req->key_len); alloca_used = false; diff --git a/nscd/nscd.c b/nscd/nscd.c index 1ae419be49..3257e05689 100644 --- a/nscd/nscd.c +++ b/nscd/nscd.c @@ -305,18 +305,18 @@ parse_opt (int key, char *arg, struct argp_state *state) error (4, 0, _("Only root is allowed to use this option!")); { int sock = nscd_open_socket (); - request_header req; - ssize_t nbytes; if (sock == -1) exit (EXIT_FAILURE); + request_header req; req.version = NSCD_VERSION; req.type = SHUTDOWN; req.key_len = 0; - nbytes = TEMP_FAILURE_RETRY (send (sock, &req, - sizeof (request_header), - MSG_NOSIGNAL)); + + ssize_t nbytes = TEMP_FAILURE_RETRY (send (sock, &req, + sizeof (request_header), + MSG_NOSIGNAL)); close (sock); exit (nbytes != sizeof (request_header) ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -335,7 +335,6 @@ parse_opt (int key, char *arg, struct argp_state *state) if (sock == -1) exit (EXIT_FAILURE); - request_header req; dbtype cnt; for (cnt = pwddb; cnt < lastdb; ++cnt) if (strcmp (arg, dbnames[cnt]) == 0) @@ -344,19 +343,24 @@ parse_opt (int key, char *arg, struct argp_state *state) if (cnt == lastdb) return ARGP_ERR_UNKNOWN; - req.key_len = strlen (arg) + 1; - req.version = NSCD_VERSION; - req.type = INVALIDATE; + size_t arg_len = strlen (arg) + 1; + struct + { + request_header req; + char arg[arg_len]; + } reqdata; - struct iovec iov[2]; - iov[0].iov_base = &req; - iov[0].iov_len = sizeof (req); - iov[1].iov_base = arg; - iov[1].iov_len = req.key_len; + reqdata.req.key_len = strlen (arg) + 1; + reqdata.req.version = NSCD_VERSION; + reqdata.req.type = INVALIDATE; + memcpy (reqdata.arg, arg, arg_len); - ssize_t nbytes = TEMP_FAILURE_RETRY (writev (sock, iov, 2)); + ssize_t nbytes = TEMP_FAILURE_RETRY (send (sock, &reqdata, + sizeof (request_header) + + arg_len, + MSG_NOSIGNAL)); - if (nbytes != iov[0].iov_len + iov[1].iov_len) + if (nbytes != sizeof (request_header) + arg_len) { int err = errno; close (sock); diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index 577c6a052a..1f56ccf6aa 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -108,6 +108,7 @@ open_socket (request_type type, const char *key, size_t keylen) request_header req; char key[keylen]; } reqdata; + size_t real_sizeof_reqdata = sizeof (request_header) + keylen; /* Make socket non-blocking. */ __fcntl (sock, F_SETFL, O_RDWR | O_NONBLOCK); @@ -135,9 +136,9 @@ open_socket (request_type type, const char *key, size_t keylen) # define MSG_NOSIGNAL 0 #endif ssize_t wres = TEMP_FAILURE_RETRY (__send (sock, &reqdata, - sizeof (reqdata), + real_sizeof_reqdata, MSG_NOSIGNAL)); - if (__builtin_expect (wres == (ssize_t) sizeof (reqdata), 1)) + if (__builtin_expect (wres == (ssize_t) real_sizeof_reqdata, 1)) /* We managed to send the request. */ return sock; diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c index 0461ec91ce..ab41bcc0d5 100644 --- a/nscd/pwdcache.c +++ b/nscd/pwdcache.c @@ -274,6 +274,7 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req, { /* Adjust pointer into the memory block. */ cp = (char *) newp + (cp - (char *) dataset); + key_copy = (char *) newp + (key_copy - (char *) dataset); dataset = memcpy (newp, dataset, total + n); alloca_used = false; diff --git a/nscd/servicescache.c b/nscd/servicescache.c index ea4fa35100..8c3a9516ba 100644 --- a/nscd/servicescache.c +++ b/nscd/servicescache.c @@ -264,8 +264,8 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req, { /* Adjust pointers into the memory block. */ aliases = (char *) newp + (aliases - (char *) dataset); - if (key_copy != NULL) - key_copy = (char *) newp + (key_copy - (char *) dataset); + assert (key_copy != NULL); + key_copy = (char *) newp + (key_copy - (char *) dataset); dataset = memcpy (newp, dataset, total + req->key_len); alloca_used = false; |