diff options
author | Volker Lendecke <vl@samba.org> | 2008-03-11 12:53:50 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-03-11 17:09:20 +0100 |
commit | 0e5d6c0d27c29645a2e72498a2a4f4b3ab8b19cd (patch) | |
tree | 98da54e129f37d429d0f24753482ca8848cd8288 /source3 | |
parent | 41bea30dd8486424c1f1fc9ebf6283f75c62e3da (diff) | |
download | samba-0e5d6c0d27c29645a2e72498a2a4f4b3ab8b19cd.tar.gz samba-0e5d6c0d27c29645a2e72498a2a4f4b3ab8b19cd.tar.bz2 samba-0e5d6c0d27c29645a2e72498a2a4f4b3ab8b19cd.zip |
Clean up add_mapping_entry slightly
(This used to be commit 38bb69cb316ba605a6d3a4454b986cb63ace3c21)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/groupdb/mapping_tdb.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c index 555f77f6f3..31937840d9 100644 --- a/source3/groupdb/mapping_tdb.c +++ b/source3/groupdb/mapping_tdb.c @@ -91,27 +91,30 @@ static bool init_group_mapping(void) static bool add_mapping_entry(GROUP_MAP *map, int flag) { TDB_DATA dbuf; - char *key = NULL; - char *buf = NULL; - fstring string_sid=""; + char *key, *buf, *sid_string; int len; bool ret; - sid_to_fstring(string_sid, &map->sid); + sid_string = sid_string_talloc(talloc_tos(), &map->sid); + if (sid_string == NULL) { + return NULL; + } len = tdb_pack(NULL, sizeof(buf), "ddff", map->gid, map->sid_name_use, map->nt_name, map->comment); if (len) { - buf = SMB_MALLOC_ARRAY(char, len); + buf = TALLOC_ARRAY(sid_string, char, len); if (!buf) { + TALLOC_FREE(sid_string); return false; } len = tdb_pack((uint8 *)buf, len, "ddff", map->gid, map->sid_name_use, map->nt_name, map->comment); } - if (asprintf(&key, "%s%s", GROUP_PREFIX, string_sid) < 0) { - SAFE_FREE(buf); + key = talloc_asprintf(sid_string, "%s%s", GROUP_PREFIX, sid_string); + if (key == NULL) { + TALLOC_FREE(sid_string); return false; } @@ -120,8 +123,7 @@ static bool add_mapping_entry(GROUP_MAP *map, int flag) ret = (tdb_store_bystring(tdb, key, dbuf, flag) == 0); - SAFE_FREE(key); - SAFE_FREE(buf); + TALLOC_FREE(sid_string); return ret; } |