dbwrap: Do not rely on dbwrap_record_get_value to return a talloc object
authorVolker Lendecke <vl@samba.org>
Thu, 29 Nov 2012 15:45:15 +0000 (16:45 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 29 Nov 2012 19:21:50 +0000 (20:21 +0100)
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 <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Thu Nov 29 20:21:51 CET 2012 on sn-devel-104

source3/lib/dbwrap/dbwrap_watch.c

index 701ac9d02f2c6ddae2750fde7686d6df4ae8a393..d7392a32353c5c3bfccffec54c44e004e32a9f1d 100644 (file)
@@ -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;