diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-08-10 11:33:42 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:38:37 -0500 |
commit | 7b453b655562cbf2eb6743c2d0fd85cca68700d3 (patch) | |
tree | a5daaf335108d18dd9f7e8c53fd606fc31a3d3e0 /source3/lib/tdb_multikey.c | |
parent | 108009f2681726691da4dfbad1e1a628f6a53f44 (diff) | |
download | samba-7b453b655562cbf2eb6743c2d0fd85cca68700d3.tar.gz samba-7b453b655562cbf2eb6743c2d0fd85cca68700d3.tar.xz samba-7b453b655562cbf2eb6743c2d0fd85cca68700d3.zip |
r17477: Add talloc_asprintf_len and make use of it.
Volker
(This used to be commit c0ff2afe0683095401fa7b7654aa3b2fe950f7b3)
Diffstat (limited to 'source3/lib/tdb_multikey.c')
-rw-r--r-- | source3/lib/tdb_multikey.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/source3/lib/tdb_multikey.c b/source3/lib/tdb_multikey.c index e8febd6f7b..7701845a9e 100644 --- a/source3/lib/tdb_multikey.c +++ b/source3/lib/tdb_multikey.c @@ -140,13 +140,14 @@ NTSTATUS tdb_find_keyed(TALLOC_CTX *ctx, struct tdb_context *tdb, prim.dptr = data.dptr = NULL; - key.dptr = talloc_asprintf(ctx, "KEY/%d/%s", keynumber, value); + key.dsize = talloc_asprintf_len(ctx, &key.dptr, "KEY/%d/%s", keynumber, + value); if (key.dptr == NULL) { DEBUG(0, ("talloc_asprintf failed\n")); status = NT_STATUS_NO_MEMORY; goto fail; } - key.dsize = strlen(key.dptr)+1; + key.dsize += 1; prim = tdb_fetch(tdb, key); if (prim.dptr == NULL) { @@ -214,13 +215,14 @@ static NTSTATUS set_keys(struct tdb_context *tdb, NTSTATUS status; TDB_DATA key; - key.dptr = talloc_asprintf(keys, "KEY/%d/%s", i, keys[i]); + key.dsize = talloc_asprintf_len(keys, &key.dptr, "KEY/%d/%s", + i, keys[i]); if (key.dptr == NULL) { DEBUG(0, ("talloc_asprintf failed\n")); TALLOC_FREE(keys); return NT_STATUS_NO_MEMORY; } - key.dsize = strlen(key.dptr)+1; + key.dsize += 1; if (tdb_store(tdb, key, primary_key, TDB_INSERT) < 0) { status = map_ntstatus_from_tdb(tdb); @@ -273,13 +275,14 @@ static NTSTATUS del_keys(struct tdb_context *tdb, NTSTATUS status; TDB_DATA key; - key.dptr = talloc_asprintf(keys, "KEY/%d/%s", i, keys[i]); + key.dsize = talloc_asprintf_len(keys, &key.dptr, "KEY/%d/%s", + i, keys[i]); if (key.dptr == NULL) { DEBUG(0, ("talloc_asprintf failed\n")); TALLOC_FREE(keys); return NT_STATUS_NO_MEMORY; } - key.dsize = strlen(key.dptr)+1; + key.dsize += 1; if (tdb_delete(tdb, key) < 0) { status = map_ntstatus_from_tdb(tdb); |