aboutsummaryrefslogtreecommitdiff
path: root/nscd/grpcache.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-08-25 17:24:52 +0000
committerUlrich Drepper <drepper@redhat.com>2004-08-25 17:24:52 +0000
commitd6db09753a9d33d5f5b98d402b01a2b168ac7785 (patch)
treecb637742eee00b837dbd8db1d777061e12ec2998 /nscd/grpcache.c
parent801ddb6a034c436be7e9ede6865aa2bd39ecfa3c (diff)
downloadglibc-d6db09753a9d33d5f5b98d402b01a2b168ac7785.zip
glibc-d6db09753a9d33d5f5b98d402b01a2b168ac7785.tar.gz
glibc-d6db09753a9d33d5f5b98d402b01a2b168ac7785.tar.bz2
Update.
2004-08-25 Ulrich Drepper <drepper@redhat.com> * nscd/connections.c: Make socket nonblocking so that threads don't get stuck on accept. Fix locking. * nscd/grpcache.c (cache_addgr): Use cope of original key in hash entry with alternative key. * nscd/pwdcache.c (cache_addpw): Likewise.
Diffstat (limited to 'nscd/grpcache.c')
-rw-r--r--nscd/grpcache.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/nscd/grpcache.c b/nscd/grpcache.c
index 2ad6251..8f5238f 100644
--- a/nscd/grpcache.c
+++ b/nscd/grpcache.c
@@ -140,7 +140,7 @@ cache_addgr (struct database *db, int fd, request_header *req, void *key,
total = (sizeof (struct groupdata)
+ gr_mem_cnt * sizeof (uint32_t)
+ gr_name_len + gr_passwd_len + gr_mem_len_total);
- data = (struct groupdata *) malloc (total + n);
+ data = (struct groupdata *) malloc (total + n + req->key_len);
if (data == NULL)
/* There is no reason to go on. */
error (EXIT_FAILURE, errno, _("while allocating cache entry"));
@@ -163,9 +163,12 @@ cache_addgr (struct database *db, int fd, request_header *req, void *key,
for (cnt = 0; cnt < gr_mem_cnt; ++cnt)
cp = mempcpy (cp, grp->gr_mem[cnt], gr_mem_len[cnt]);
- /* Finally the stringified GID value. */
+ /* Next the stringified GID value. */
memcpy (cp, buf, n);
+ /* Copy of the key in case it differs. */
+ char *key_copy = memcpy (cp + n, key, req->key_len);
+
/* Write the result. */
written = TEMP_FAILURE_RETRY (write (fd, &data->resp, total));
@@ -180,8 +183,8 @@ cache_addgr (struct database *db, int fd, request_header *req, void *key,
total, data, 0, t, db, owner);
/* If the key is different from the name add a separate entry. */
- if (type == GETGRBYNAME && strcmp (key, gr_name) != 0)
- cache_add (GETGRBYNAME, key, strlen (key) + 1, data,
+ if (type == GETGRBYNAME && strcmp (key_copy, gr_name) != 0)
+ cache_add (GETGRBYNAME, key_copy, req->key_len, data,
total, data, 0, t, db, owner);
cache_add (GETGRBYGID, cp, n, data, total, data, 1, t, db, owner);