gnome-keyring r1706 - in trunk: . egg



Author: stefw
Date: Thu Apr  2 03:29:53 2009
New Revision: 1706
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1706&view=rev

Log:
Fix assertion that occurs when shrinking block of secure memory and then expanding again.

Modified:
   trunk/ChangeLog
   trunk/egg/egg-secure-memory.c

Modified: trunk/egg/egg-secure-memory.c
==============================================================================
--- trunk/egg/egg-secure-memory.c	(original)
+++ trunk/egg/egg-secure-memory.c	Thu Apr  2 03:29:53 2009
@@ -625,7 +625,7 @@
 	/* How many words we actually want */
 	n_words = sec_size_to_words (length) + 2;
 
-	/* Less memory is required */
+	/* Less memory is required than is in the cell */
 	if (n_words <= cell->n_words) {
 
 		/* TODO: No shrinking behavior yet */
@@ -636,7 +636,15 @@
 		VALGRIND_MAKE_MEM_DEFINED (alloc, length);
 #endif
 		
-		return sec_clear_memory (alloc, valid, length);
+		/* 
+		 * Even though we may be reusing the same cell, that doesn't
+		 * mean that the allocation is shrinking. It could have shrunk
+		 * and is now expanding back some. 
+		 */ 
+		if (length < valid)
+			return sec_clear_memory (alloc, length, valid);
+		else
+			return alloc;
 	}
 	
 	/* Need braaaaaiiiiiinsss... */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]