* nscd/grpcache.c (cache_addgr): Correctly compute size of cvs/fedora-glibc-20080612T1619
authorUlrich Drepper <drepper@redhat.com>
Thu, 12 Jun 2008 16:16:38 +0000 (16:16 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 12 Jun 2008 16:16:38 +0000 (16:16 +0000)
fixed-size portion of the record.
* nscd/servicescache.c (cache_addserv): Likewise.
* nscd/pwdcache.c (cache_addpw): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.

ChangeLog
nptl/ChangeLog
nptl/sysdeps/pthread/pthread.h
nscd/grpcache.c
nscd/initgrcache.c
nscd/pwdcache.c
nscd/servicescache.c

index 92cda30..c9e36fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-06-12  Ulrich Drepper  <drepper@redhat.com>
+
+       * nscd/grpcache.c (cache_addgr): Correctly compute size of
+       fixed-size portion of the record.
+       * nscd/servicescache.c (cache_addserv): Likewise.
+       * nscd/pwdcache.c (cache_addpw): Likewise.
+       * nscd/initgrcache.c (addinitgroupsX): Likewise.
+
 2008-06-11  Ulrich Drepper  <drepper@redhat.com>
 
        * nscd/mem.c (gc): Initialize obstack earlier so that if we jump
index aee0f51..744f90d 100644 (file)
@@ -1,3 +1,7 @@
+2008-06-12  Ulrich Drepper  <drepper@redhat.com>
+
+       * sysdeps/pthread/pthread.h: Remove inadvertant checkin.
+
 2008-05-17  Samuel Thibault  <samuel.thibault@ens-lyon.org>
 
        * sysdeps/pthread/pthread.h: Fix typo in comment.
index 331a441..d5ffd38 100644 (file)
@@ -122,12 +122,12 @@ enum
 
 /* Read-write lock initializers.  */
 # define PTHREAD_RWLOCK_INITIALIZER \
-  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
+  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
 # ifdef __USE_GNU
 #  if __WORDSIZE == 64
 #   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
   { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,                                          \
-       PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, 0 } }
+       PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
 #  else
 #   if __BYTE_ORDER == __LITTLE_ENDIAN
 #    define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
index e391dc3..c49c0e1 100644 (file)
@@ -190,7 +190,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
          gr_mem_len_total += gr_mem_len[gr_mem_cnt];
        }
 
-      written = total = (sizeof (struct dataset)
+      written = total = (offsetof (struct dataset, strdata)
                         + gr_mem_cnt * sizeof (uint32_t)
                         + gr_name_len + gr_passwd_len + gr_mem_len_total);
 
@@ -252,6 +252,9 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
       char *key_copy = cp + key_offset;
       assert (key_copy == (char *) rawmemchr (cp, '\0') + 1);
 
+      assert (cp == dataset->strdata + total - offsetof (struct dataset,
+                                                        strdata));
+
       /* Now we can determine whether on refill we have to create a new
         record or not.  */
       if (he != NULL)
index 3355df5..c5693c6 100644 (file)
@@ -246,7 +246,8 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
   else
     {
 
-      written = total = sizeof (struct dataset) + start * sizeof (int32_t);
+      written = total = (offsetof (struct dataset, strdata)
+                        + start * sizeof (int32_t));
 
       /* If we refill the cache, first assume the reconrd did not
         change.  Allocate memory on the cache since it is likely
@@ -307,6 +308,9 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
       /* Finally the user name.  */
       memcpy (cp, key, req->key_len);
 
+      assert (cp == dataset->strdata + total - offsetof (struct dataset,
+                                                        strdata));
+
       /* Now we can determine whether on refill we have to create a new
         record or not.  */
       if (he != NULL)
index 4a0cabd..782b101 100644 (file)
@@ -185,7 +185,8 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
       n = snprintf (buf, buf_len, "%d%c%n%s", pwd->pw_uid, '\0',
                    &key_offset, (char *) key) + 1;
 
-      written = total = (sizeof (struct dataset) + pw_name_len + pw_passwd_len
+      written = total = (offsetof (struct dataset, strdata)
+                        + pw_name_len + pw_passwd_len
                         + pw_gecos_len + pw_dir_len + pw_shell_len);
 
       /* If we refill the cache, first assume the reconrd did not
@@ -247,16 +248,28 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
       char *key_copy = cp + key_offset;
       assert (key_copy == (char *) rawmemchr (cp, '\0') + 1);
 
+      assert (cp == dataset->strdata + total - offsetof (struct dataset,
+                                                        strdata));
+
       /* Now we can determine whether on refill we have to create a new
         record or not.  */
       if (he != NULL)
        {
          assert (fd == -1);
 
-         if (total + n == dh->allocsize
-             && total - offsetof (struct dataset, resp) == dh->recsize
+#if 0
+         if (dataset->head.datasize == dh->allocsize
+             && dataset->head.recsize == dh->recsize
              && memcmp (&dataset->resp, dh->data,
                         dh->allocsize - offsetof (struct dataset, resp)) == 0)
+#else
+         if (dataset->head.allocsize != dh->allocsize)
+           goto nnn;
+         if (dataset->head.recsize != dh->recsize)
+           goto nnn;
+         if(memcmp (&dataset->resp, dh->data,
+                        dh->allocsize - offsetof (struct dataset, resp)) == 0)
+#endif
            {
              /* The data has not changed.  We will just bump the
                 timeout value.  Note that the new record has been
@@ -266,6 +279,7 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
            }
          else
            {
+ nnn:;
              /* We have to create a new record.  Just allocate
                 appropriate memory and copy it.  */
              struct dataset *newp
index c952fa1..44f12a3 100644 (file)
@@ -173,7 +173,7 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req,
          total += s_aliases_len[cnt];
        }
 
-      total += (sizeof (struct dataset)
+      total += (offsetof (struct dataset, strdata)
                + s_name_len
                + s_proto_len
                + s_aliases_cnt * sizeof (uint32_t));