Skip to content

Commit 495ca09

Browse files
s4/ldap server: avoid NULL deref if search control has no data
We switch to ldb_request_replace_control() so that the old search control is removed in the NULL data case. Signed-off-by: Douglas Bagnall <[email protected]> Reviewed-by: Volker Lendecke <[email protected]>
1 parent b85f056 commit 495ca09

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source4/ldap_server/ldap_backend.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,14 +858,18 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
858858
search_control = ldb_request_get_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID);
859859

860860
search_options = NULL;
861-
if (search_control) {
861+
if (search_control != NULL && search_control->data != NULL) {
862862
search_options = talloc_get_type(search_control->data, struct ldb_search_options_control);
863863
search_options->search_options |= LDB_SEARCH_OPTION_PHANTOM_ROOT;
864864
} else {
865865
search_options = talloc(lreq, struct ldb_search_options_control);
866866
NT_STATUS_HAVE_NO_MEMORY(search_options);
867867
search_options->search_options = LDB_SEARCH_OPTION_PHANTOM_ROOT;
868-
ldb_request_add_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID, false, search_options);
868+
ldb_request_replace_control(
869+
lreq,
870+
LDB_CONTROL_SEARCH_OPTIONS_OID,
871+
false,
872+
search_options);
869873
}
870874
} else {
871875
ldb_request_add_control(lreq, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);

0 commit comments

Comments
 (0)