]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
paged_results: add no memory checks in paged_search()
authorStefan Metzmacher <metze@samba.org>
Mon, 7 Feb 2022 23:41:54 +0000 (00:41 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 2 Aug 2023 11:16:41 +0000 (11:16 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15442

Signed-off-by: Arvid Requate <requate@univention.de>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
[abartlet@samba.org combination of two patches by the above authors]

source4/dsdb/samdb/ldb_modules/paged_results.c

index 2063e84e1579a2c4263c71b24f79b7210aed99d1..a6f2bf22098fdad266f1466570509eccaf803d55 100644 (file)
@@ -705,9 +705,15 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
                        struct ldb_request *req_extended_dn;
                        struct ldb_extended_dn_control *ext_ctrl_data;
                        req_extended_dn = talloc_zero(req, struct ldb_request);
+                       if (req_extended_dn == NULL) {
+                               return ldb_module_oom(module);
+                       }
                        req_extended_dn->controls = req->controls;
                        ext_ctrl_data = talloc_zero(req,
                                        struct ldb_extended_dn_control);
+                       if (ext_ctrl_data == NULL) {
+                               return ldb_module_oom(module);
+                       }
                        ext_ctrl_data->type = 1;
 
                        ret = ldb_request_add_control(req_extended_dn,
@@ -736,8 +742,16 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
                ac->store->expr = talloc_steal(ac->store, req->op.search.tree);
                ac->store->expr_str = ldb_filter_from_tree(ac->store,
                                                          req->op.search.tree);
-               ac->store->attrs = paged_copy_attrs(ac->store,
-                                                   req->op.search.attrs);
+               if (ac->store->expr_str == NULL) {
+                       return ldb_module_oom(module);
+               }
+               if (req->op.search.attrs != NULL) {
+                       ac->store->attrs = paged_copy_attrs(ac->store,
+                                                           req->op.search.attrs);
+                       if (ac->store->attrs == NULL) {
+                               return ldb_module_oom(module);
+                       }
+               }
 
                /* save it locally and remove it from the list */
                /* we do not need to replace them later as we