[PATCH] Make tdb record deletion circular-chain safe

Volker Lendecke Volker.Lendecke at SerNet.DE
Sat Nov 3 09:17:29 UTC 2018


On Mon, Oct 29, 2018 at 02:37:04PM -0700, Jeremy Allison via samba-technical wrote:
> On Thu, Oct 25, 2018 at 09:12:44PM +0200, Volker Lendecke via samba-technical wrote:
> and are comparing it to tdb->max_dead_records,
> which is a uint32_t. However tdb->max_dead_records
> is only ever initialized as follows:

I think it's the other way round. tdb_private.h has

        int max_dead_records;

which IMHO is wrong but not worth chainging our API for.

See the attached patch.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From deb54ede62b68d4f2a2bec8f25d302999a673f79 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 3 Nov 2018 10:11:26 +0100
Subject: [PATCH] tdb: Align integer types

tdb->max_dead_records is "int", as is the corresponding parameter to
tdb_set_max_dead(). Not that a signed variable makes any sense, but
this is old code and tdb_set_max_dead() is a public API which we
should not change for this.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/tdb/common/freelist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tdb/common/freelist.c b/lib/tdb/common/freelist.c
index 90643862208..37a4c168533 100644
--- a/lib/tdb/common/freelist.c
+++ b/lib/tdb/common/freelist.c
@@ -557,7 +557,7 @@ static bool tdb_alloc_dead(
 
 static void tdb_purge_dead(struct tdb_context *tdb, uint32_t hash)
 {
-	uint32_t max_dead_records = tdb->max_dead_records;
+	int max_dead_records = tdb->max_dead_records;
 
 	tdb->max_dead_records = 0;
 
-- 
2.11.0



More information about the samba-technical mailing list