Bug in tdb (Doesn't affect samba)

Rui Barreiros rbarreiros at evoluta.pt
Wed Apr 14 18:26:35 GMT 2004


Hi there,

I'me sending this mail to here because i'm afraid that no member in the
sourceforge project of tdb doesn't read it, because the changes in CVS
are from 2 year ago...

The 2 bug's don't affect samba since samba doesn't use key locking.
I found them after building a PHP module for acessing tdb databases,
soon will be released, and if there is any interest i'll announce it
here.

Attached is the patch against latest head cvs (3.0)

Best wishes to all,

-- 
Rui Barreiros

Evoluta - Tecnologias de Informação
Rua do Padrão nº 58 2º Andar Sala 25
4415-284 Carvalhos
Tel: 227839464 Fax: 227839465
http://www.evoluta.pt
-------------- next part --------------
--- tdb.c	2004-04-14 19:05:46.000000000 +0100
+++ tdb_new.c	2004-04-14 19:25:19.000000000 +0100
@@ -1026,9 +1026,12 @@
 	u32 i;
 	if (!tdb->lockedkeys)
 		return 1;
+
+        // BUG FIX * Rui Barreiros * BUG FIX
+        // returns 1 but should return 0 !!!!!! (The only function that doesn't follow the rule of returning 0 on success is tdb_keyexists
 	for (i = 0; i < tdb->lockedkeys[0]; i++)
 		if (tdb->lockedkeys[i+1] == hash)
-			return 1;
+			return 0;
 	return TDB_ERRCODE(TDB_ERR_NOLOCK, 0);
 }
 
@@ -1999,8 +2002,14 @@
 	u32 i;
 	if (!tdb->lockedkeys)
 		return;
+
+        /*
+          BUG FIX * Rui Barreiros * BUG FIX
+          the second argument of tdb_unlock should be an index not the hash value of the locked key
+          old line: tdb_unlock(tdb, tdb->lockedkeys[i+1], F_WRLCK);
+	*/
 	for (i = 0; i < tdb->lockedkeys[0]; i++)
-		tdb_unlock(tdb, tdb->lockedkeys[i+1], F_WRLCK);
+		tdb_unlock(tdb, i, F_WRLCK);
 	SAFE_FREE(tdb->lockedkeys);
 }
 


More information about the samba-technical mailing list