[PATCH] group_mapping: Avoid a talloc

Volker Lendecke Volker.Lendecke at SerNet.DE
Wed Jan 8 02:59:03 MST 2014


Hi!

Please review & push!

Thanks,

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 d77f1d4eb1a102975ee46328e559740b5b1248db Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 3 Dec 2013 16:01:35 +0100
Subject: [PATCH] group_mapping: Avoid a talloc

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/groupdb/mapping_tdb.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index 088874f..05b6fce 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -119,17 +119,15 @@ static bool init_group_mapping(void)
 
 static char *group_mapping_key(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
 {
-	char *sidstr, *result;
+	char sidstr[DOM_SID_STR_BUFLEN];
+	int len;
 
-	sidstr = sid_string_talloc(talloc_tos(), sid);
-	if (sidstr == NULL) {
-		return NULL;
+	len = dom_sid_string_buf(sid, sidstr, sizeof(sidstr));
+	if (len >= sizeof(sidstr)) {
+		return false;
 	}
 
-	result = talloc_asprintf(mem_ctx, "%s%s", GROUP_PREFIX, sidstr);
-
-	TALLOC_FREE(sidstr);
-	return result;
+	return talloc_asprintf(mem_ctx, "%s%s", GROUP_PREFIX, sidstr);
 }
 
 /****************************************************************************
-- 
1.7.9.5



More information about the samba-technical mailing list