about summary refs log tree commit diff
path: root/nscd/hstcache.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-08-22 03:30:02 +0000
committerUlrich Drepper <drepper@redhat.com>2007-08-22 03:30:02 +0000
commitc44d3bdf14b75389f1fea86bfb03c9c38ea40f17 (patch)
tree388702593c49b2a7b0bdccc6872f3fcb5e348b32 /nscd/hstcache.c
parent1ce7d80ddc62d4bb3e8e4f89fbcb6fa21361733d (diff)
downloadglibc-c44d3bdf14b75389f1fea86bfb03c9c38ea40f17.tar.gz
glibc-c44d3bdf14b75389f1fea86bfb03c9c38ea40f17.tar.xz
glibc-c44d3bdf14b75389f1fea86bfb03c9c38ea40f17.zip
[BZ #4905]
	* nscd/hstcache.c (cache_addhst): When reloading an entry which
	suddenly has two or more addresses, ignore it and remove the old
	entry.
Diffstat (limited to 'nscd/hstcache.c')
-rw-r--r--nscd/hstcache.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index 74de8f6567..54222a3408 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -298,25 +298,31 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
 	      /* The data has not changed.  We will just bump the
 		 timeout value.  Note that the new record has been
 		 allocated on the stack and need not be freed.  */
+	      assert (h_addr_list_cnt == 1);
 	      dh->timeout = dataset->head.timeout;
 	      ++dh->nreloads;
 	    }
 	  else
 	    {
-	      /* We have to create a new record.  Just allocate
-		 appropriate memory and copy it.  */
-	      struct dataset *newp
-		= (struct dataset *) mempool_alloc (db, total + req->key_len);
-	      if (newp != NULL)
+	      if (h_addr_list_cnt == 1)
 		{
-		  /* Adjust pointers into the memory block.  */
-		  addresses = (char *) newp + (addresses - (char *) dataset);
-		  aliases = (char *) newp + (aliases - (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;
+		  /* We have to create a new record.  Just allocate
+		     appropriate memory and copy it.  */
+		  struct dataset *newp
+		    = (struct dataset *) mempool_alloc (db,
+							total + req->key_len);
+		  if (newp != NULL)
+		    {
+		      /* Adjust pointers into the memory block.  */
+		      addresses = (char *) newp + (addresses
+						   - (char *) dataset);
+		      aliases = (char *) newp + (aliases - (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;
+		    }
 		}
 
 	      /* Mark the old record as obsolete.  */