lib/ldb-samba: Use ndr_push_struct_into_fixed_blob() in ldif_handlers.c
authorAndrew Bartlett <abartlet@samba.org>
Sun, 26 Jun 2016 22:52:55 +0000 (10:52 +1200)
committerStefan Metzmacher <metze@samba.org>
Thu, 28 Jul 2016 08:06:12 +0000 (10:06 +0200)
This avoids a number of pointless and pointlessly-large allocations
in inner loops.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb-samba/ldif_handlers.c

index c0972a4a6a75ade4fe0d97c0984e5c4b77233e60..510154d4aa091bd1bb1db5bb7e95f197d4c3b094 100644 (file)
@@ -91,8 +91,15 @@ static int ldif_read_objectSid(struct ldb_context *ldb, void *mem_ctx,
        if (sid == NULL) {
                return -1;
        }
-       ndr_err = ndr_push_struct_blob(out, mem_ctx, sid,
-                                      (ndr_push_flags_fn_t)ndr_push_dom_sid);
+
+       *out = data_blob_talloc(mem_ctx, NULL,
+                               ndr_size_dom_sid(sid, 0));
+       if (out->data == NULL) {
+               return -1;
+       }
+       
+       ndr_err = ndr_push_struct_into_fixed_blob(out, sid,
+                       (ndr_push_flags_fn_t)ndr_push_dom_sid);
        talloc_free(sid);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return -1;