CVE-2020-10760 dsdb: Ensure a proper talloc tree for saved controls
[vlendec/samba-autobuild/.git] / source4 / dsdb / samdb / ldb_modules / vlv_pagination.c
index b103bda5f520534110908cdd90dab4a7b8529b7f..d6d6039e849281389dd02ed58c76e632f8c0cd62 100644 (file)
@@ -746,6 +746,13 @@ vlv_copy_down_controls(TALLOC_CTX *mem_ctx, struct ldb_control **controls)
                        continue;
                }
                new_controls[j] = talloc_steal(new_controls, control);
+               /*
+                * Sadly the caller is not obliged to make this a
+                * proper talloc tree, so we do so here.
+                */
+               if (control->data) {
+                       talloc_steal(control, control->data);
+               }
                j++;
        }
        new_controls[j] = NULL;