s3:idmap_tdb: add tmp talloc ctx to idmap_tdb_sid_to_id and remove an fstring
authorMichael Adam <obnox@samba.org>
Thu, 22 Jan 2009 23:52:28 +0000 (00:52 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 6 Feb 2009 09:20:06 +0000 (10:20 +0100)
Michael

source3/winbindd/idmap_tdb.c

index 481ac1b9ad6095bb548a1442f5fdcc07d121247d..f2557cc2e6b97daca63a9323f1b176818feef43d 100644 (file)
@@ -694,10 +694,10 @@ static NTSTATUS idmap_tdb_sid_to_id(struct idmap_tdb_context *ctx, struct id_map
        TDB_DATA data;
        char *keystr;
        unsigned long rec_id = 0;
-       fstring tmp;
+       TALLOC_CTX *tmp_ctx = talloc_stackframe();
 
-       if ((keystr = talloc_asprintf(
-                    ctx, "%s", sid_to_fstring(tmp, map->sid))) == NULL) {
+       keystr = sid_string_talloc(tmp_ctx, map->sid);
+       if (keystr == NULL) {
                DEBUG(0, ("Out of memory!\n"));
                ret = NT_STATUS_NO_MEMORY;
                goto done;
@@ -706,7 +706,7 @@ static NTSTATUS idmap_tdb_sid_to_id(struct idmap_tdb_context *ctx, struct id_map
        DEBUG(10,("Fetching record %s\n", keystr));
 
        /* Check if sid is present in database */
-       data = dbwrap_fetch_bystring(ctx->db, NULL, keystr);
+       data = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr);
        if (!data.dptr) {
                DEBUG(10,("Record %s not found\n", keystr));
                ret = NT_STATUS_NONE_MAPPED;
@@ -730,8 +730,6 @@ static NTSTATUS idmap_tdb_sid_to_id(struct idmap_tdb_context *ctx, struct id_map
                DEBUG(2, ("Found INVALID record %s -> %s\n", keystr, (const char *)data.dptr));
                ret = NT_STATUS_INTERNAL_DB_ERROR;
        }
-       
-       TALLOC_FREE(data.dptr);
 
        /* apply filters before returning result */
        if ((ctx->filter_low_id && (map->xid.id < ctx->filter_low_id)) ||
@@ -742,7 +740,7 @@ static NTSTATUS idmap_tdb_sid_to_id(struct idmap_tdb_context *ctx, struct id_map
        }
 
 done:
-       talloc_free(keystr);
+       talloc_free(tmp_ctx);
        return ret;
 }