svn commit: samba r12221 - in branches/SAMBA_3_0/source/locking: .

jra at samba.org jra at samba.org
Wed Dec 14 00:42:41 GMT 2005


Author: jra
Date: 2005-12-14 00:42:40 +0000 (Wed, 14 Dec 2005)
New Revision: 12221

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12221

Log:
Fix error code paths that can potentially leave a dangling lock.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/locking/locking.c


Changeset:
Modified: branches/SAMBA_3_0/source/locking/locking.c
===================================================================
--- branches/SAMBA_3_0/source/locking/locking.c	2005-12-13 22:37:04 UTC (rev 12220)
+++ branches/SAMBA_3_0/source/locking/locking.c	2005-12-14 00:42:40 UTC (rev 12221)
@@ -595,12 +595,18 @@
 		return NULL;
 	}
 
+	/* Ensure we set every field here as the destructor must be
+	   valid even if parse_share_modes fails. */
+
+	lck->servicepath = NULL;
+	lck->filename = NULL;
 	lck->dev = dev;
 	lck->ino = ino;
-	lck->delete_on_close = False;
 	lck->num_share_modes = 0;
 	lck->share_modes = NULL;
+	lck->delete_on_close = False;
 	lck->modified = False;
+	lck->fresh = False;
 
 	if (tdb_chainlock(tdb, key) != 0) {
 		DEBUG(3, ("Could not lock share entry\n"));
@@ -608,6 +614,12 @@
 		return NULL;
 	}
 
+	/* We must set the destructor immediately after the chainlock
+	   ensure the lock is cleaned up on any of the error return
+	   paths below. */
+
+	talloc_set_destructor(lck, share_mode_lock_destructor);
+
 	data = tdb_fetch(tdb, key);
 	lck->fresh = (data.dptr == NULL);
 
@@ -634,7 +646,6 @@
 		}
 	}
 
-	talloc_set_destructor(lck, share_mode_lock_destructor);
 	SAFE_FREE(data.dptr);
 
 	return lck;



More information about the samba-cvs mailing list