File glibc-nscd-assert.diff of Package glibc

2009-08-18  Anders Johansson  <ajohansson@novell.com>

	* nscd/aicache.c: Fix mixing up dataset and dataset->resp
	offsets and record sizes in assert()s and response sending.
	* nscd/grpcache.c: Likewise.
	* nscd/hstcache.c: Likewise.
	* nscd/initgrcache.c: Likewise.
	* nscd/pwdcache.c: Likewise.

diff -ur glibc-2.4.orig/nscd/aicache.c glibc-2.4/nscd/aicache.c
--- nscd/aicache.c	2009-06-18 14:20:53.000000000 +0200
+++ nscd/aicache.c	2009-06-18 14:21:20.000000000 +0200
@@ -450,6 +450,6 @@
 	    {
 	      assert (db->wr_fd != -1);
 	      assert ((char *) &dataset->resp > (char *) db->data);
-	      assert ((char *) &dataset->resp - (char *) db->head + total
+	      assert ((char *) dataset - (char *) db->head + total
 		      <= (sizeof (struct database_pers_head)
 			  + db->head->module * sizeof (ref_t)
@@ -458,6 +458,6 @@
 	      ssize_t written;
 	      written = sendfileall (fd, db->wr_fd, (char *) &dataset->resp
-				     - (char *) db->head, total);
+				     - (char *) db->head, dataset->head.recsize);
 # ifndef __ASSUME_SENDFILE
 		      if (written == -1 && errno == ENOSYS)
 			goto use_write;
@@ -469,7 +469,7 @@
 		  use_write:
 # endif
 #endif
-	    writeall (fd, &dataset->resp, total);
+	    writeall (fd, &dataset->resp, dataset->head.recsize);
 	}
 
 	      goto out;
diff -ur glibc-2.4.orig/nscd/grpcache.c glibc-2.4/nscd/grpcache.c
--- nscd/grpcache.c	2009-06-18 14:20:53.000000000 +0200
+++ nscd/grpcache.c	2009-06-18 14:21:20.000000000 +0200
@@ -317,14 +317,14 @@
 	    {
 	      assert (db->wr_fd != -1);
 	      assert ((char *) &dataset->resp > (char *) db->data);
-	      assert ((char *) &dataset->resp - (char *) db->head
+	      assert ((char *) dataset - (char *) db->head
 		      + total
 		      <= (sizeof (struct database_pers_head)
 			  + db->head->module * sizeof (ref_t)
 			  + db->head->data_size));
 	      written = sendfileall (fd, db->wr_fd,
 				     (char *) &dataset->resp
-				     - (char *) db->head, total);
+				     - (char *) db->head, dataset->head.recsize);
 # ifndef __ASSUME_SENDFILE
 	      if (written == -1 && errno == ENOSYS)
 		goto use_write;
@@ -335,7 +335,7 @@
 	  use_write:
 # endif
 #endif
-	    written = writeall (fd, &dataset->resp, total);
+	    written = writeall (fd, &dataset->resp, dataset->head.recsize);
 	}
 
       /* Add the record to the database.  But only if it has not been
diff -ur glibc-2.4.orig/nscd/hstcache.c glibc-2.4/nscd/hstcache.c
--- nscd/hstcache.c	2009-06-18 14:20:53.000000000 +0200
+++ nscd/hstcache.c	2009-06-18 14:22:22.000000000 +0200
@@ -365,7 +365,7 @@
 	    {
 	      assert (db->wr_fd != -1);
 	      assert ((char *) &dataset->resp > (char *) db->data);
-	      assert ((char *) &dataset->resp - (char *) db->head
+	      assert ((char *) dataset - (char *) db->head
 		      + total
 		      <= (sizeof (struct database_pers_head)
 			  + db->head->module * sizeof (ref_t)
diff -ur glibc-2.4.orig/nscd/initgrcache.c glibc-2.4/nscd/initgrcache.c
--- nscd/initgrcache.c	2009-06-18 14:20:53.000000000 +0200
+++ nscd/initgrcache.c	2009-06-18 14:21:20.000000000 +0200
@@ -367,14 +367,14 @@
 	    {
 	      assert (db->wr_fd != -1);
 	      assert ((char *) &dataset->resp > (char *) db->data);
-	      assert ((char *) &dataset->resp - (char *) db->head
+	      assert ((char *) dataset - (char *) db->head
 		      + total
 		      <= (sizeof (struct database_pers_head)
 			  + db->head->module * sizeof (ref_t)
 			  + db->head->data_size));
 	      written = sendfileall (fd, db->wr_fd,
 				     (char *) &dataset->resp
-				     - (char *) db->head, total);
+				     - (char *) db->head, dataset->head.recsize);
 # ifndef __ASSUME_SENDFILE
 	      if (written == -1 && errno == ENOSYS)
 		goto use_write;
@@ -385,7 +385,7 @@
 	  use_write:
 # endif
 #endif
-	    written = writeall (fd, &dataset->resp, total);
+	    written = writeall (fd, &dataset->resp, dataset->head.recsize);
 	}
 
 
diff -ur glibc-2.4.orig/nscd/pwdcache.c glibc-2.4/nscd/pwdcache.c
--- nscd/pwdcache.c	2009-06-18 14:20:53.000000000 +0200
+++ nscd/pwdcache.c	2009-06-18 14:21:20.000000000 +0200
@@ -311,14 +311,14 @@
 	    {
 	      assert (db->wr_fd != -1);
 	      assert ((char *) &dataset->resp > (char *) db->data);
-	      assert ((char *) &dataset->resp - (char *) db->head
+	      assert ((char *) dataset - (char *) db->head
 		      + total
 		      <= (sizeof (struct database_pers_head)
                           + db->head->module * sizeof (ref_t)
                           + db->head->data_size));
 	      written = sendfileall (fd, db->wr_fd,
 				     (char *) &dataset->resp
-				     - (char *) db->head, total);
+				     - (char *) db->head, dataset->head.recsize );
 # ifndef __ASSUME_SENDFILE
 	      if (written == -1 && errno == ENOSYS)
 		goto use_write;
@@ -329,7 +329,7 @@
 	  use_write:
 # endif
 #endif
-	    written = writeall (fd, &dataset->resp, total);
+	    written = writeall (fd, &dataset->resp, dataset->head.recsize);
 	}
openSUSE Build Service is sponsored by