From e96307fc7648d4844893c17a3e1a3d6868d4fd64 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 29 Nov 2012 16:45:15 +0100 Subject: [PATCH] dbwrap: Fix bug 9440: Do not rely on dbwrap_record_get_value to return a talloc object db_tdb_fetch_locked returns the value as part of a larger talloc object that also contains the key. This means we can not realloc, but have to freshly alloc. Reviewed-by: Michael Adam Autobuild-User(master): Michael Adam Autobuild-Date(master): Thu Nov 29 20:21:51 CET 2012 on sn-devel-104 (cherry picked from commit 2f38a77a2dfc72ccd94f5027807c9484dae54358) --- source3/lib/dbwrap/dbwrap_watch.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c index 701ac9d..d7392a3 100644 --- a/source3/lib/dbwrap/dbwrap_watch.c +++ b/source3/lib/dbwrap/dbwrap_watch.c @@ -119,12 +119,13 @@ static NTSTATUS dbwrap_record_add_watcher(TDB_DATA w_key, struct server_id id) ids = (struct server_id *)value.dptr; num_ids = value.dsize / sizeof(struct server_id); - ids = talloc_realloc(talloc_tos(), ids, struct server_id, - num_ids + 1); + ids = talloc_array(talloc_tos(), struct server_id, + num_ids + 1); if (ids == NULL) { status = NT_STATUS_NO_MEMORY; goto fail; } + memcpy(ids, value.dptr, value.dsize); ids[num_ids] = id; num_ids += 1; -- 1.7.3.4