[vhffs-dev] [939] fix double free corruption

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 939
Author:   gradator
Date:     2007-09-21 15:48:48 +0000 (Fri, 21 Sep 2007)

Log Message:
-----------
fix double free corruption

Modified Paths:
--------------
    trunk/vhffs-fs/configure.ac
    trunk/vhffs-fs/vhffsfs.c


Modified: trunk/vhffs-fs/configure.ac
===================================================================
--- trunk/vhffs-fs/configure.ac	2007-09-21 15:20:00 UTC (rev 938)
+++ trunk/vhffs-fs/configure.ac	2007-09-21 15:48:48 UTC (rev 939)
@@ -77,7 +77,7 @@
            AC_HELP_STRING([--with-check-quota-cache-timeout],
                [???? [default=10]]), 
            AC_DEFINE([VHFFSFS_CHECKQUOTA_CACHE_TIMEOUT], $withval, [???]),
-           AC_DEFINE([VHFFSFS_CHECKQUOTA_CACHE_TIMEOUT], 30, [???]))
+           AC_DEFINE([VHFFSFS_CHECKQUOTA_CACHE_TIMEOUT], 10, [???]))
        AC_ARG_WITH([check-quota-cache-flush],
            AC_HELP_STRING([--with-check-quota-cache-flush],
                [???? [default=1800]]),

Modified: trunk/vhffs-fs/vhffsfs.c
===================================================================
--- trunk/vhffs-fs/vhffsfs.c	2007-09-21 15:20:00 UTC (rev 938)
+++ trunk/vhffs-fs/vhffsfs.c	2007-09-21 15:48:48 UTC (rev 939)
@@ -73,6 +73,7 @@
 typedef struct {
 	gid_t gid;
 	char *path;
+	char *key;
 	struct dqblk *dq;
 	time_t arrival;
 	int ref;
@@ -795,8 +796,9 @@
 	vcq->dq = dq;
 	vcq->arrival = vhffsfs_cache_arrival();
 	vcq->ref = 1;
-	g_hash_table_insert(vhffsfs.quotacacheused, key, vcq);
-	g_ptr_array_add(vhffsfs.quotacachekeys, key);
+	vcq->key = strdup(key);
+	g_hash_table_insert(vhffsfs.quotacacheused, vcq->key, vcq);
+	g_ptr_array_add(vhffsfs.quotacachekeys, vcq->key);
 	vhffsfs_checkquota_cache_unlock();
 	return vcq->dq;
 }
@@ -816,6 +818,7 @@
 	g_ptr_array_remove_fast(vhffsfs.quotacachekeys, key);
 	g_hash_table_remove(vhffsfs.quotacacheused, key);
 	free(vcq->dq);
+	free(vcq->key);
 	free(vcq);
 	vhffsfs_checkquota_cache_unlock();
 }
@@ -878,7 +881,7 @@
 		// copy keys
 		vhffsfs_checkquota_cache_lock();
 		for(i = 0 ; i < vhffsfs.quotacachekeys->len ; i++)  {
-			g_ptr_array_add(keys, vhffsfs.quotacachekeys->pdata[i]);
+			g_ptr_array_add(keys, strdup(vhffsfs.quotacachekeys->pdata[i]));
 		}
 		vhffsfs_checkquota_cache_unlock();
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/