1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

libcli/ldap: Test decoding an exop response

ldap-starttls-response.dat is a reply to a starttls extended
operation. Right now ldap_decode() does not handle this correctly.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Volker Lendecke 2020-06-23 19:14:37 +02:00
parent 92b1078e1e
commit 60b0928945
3 changed files with 44 additions and 0 deletions

Binary file not shown.

View File

@ -261,6 +261,45 @@ static void test_recursion_depth_greater_than_max(void **state)
assert_ldap_status_equal(LDAP_PROTOCOL_ERROR, status);
}
/*
* Check we can decode an exop response
*/
static void test_decode_exop_response(void **state)
{
struct test_ctx *test_ctx = talloc_get_type_abort(
*state,
struct test_ctx);
struct asn1_data *asn1;
struct ldap_message *ldap_msg;
NTSTATUS status;
FILE *f = NULL;
uint8_t *buffer = NULL;
const size_t BUFF_SIZE = 1048576;
size_t len;
struct ldap_request_limits limits = {
.max_search_size = 256000,
};
buffer = talloc_zero_array(test_ctx, uint8_t, BUFF_SIZE);
f = fopen("./libcli/ldap/tests/data/ldap-starttls-response.dat", "r");
assert_not_ferror(f);
len = fread(buffer, sizeof(uint8_t), BUFF_SIZE, f);
assert_not_ferror(f);
assert_true(len > 0);
asn1 = asn1_init(test_ctx, 3);
assert_non_null(asn1);
asn1_load_nocopy(asn1, buffer, len);
ldap_msg = talloc(test_ctx, struct ldap_message);
assert_non_null(ldap_msg);
status = ldap_decode(
asn1, &limits, samba_ldap_control_handlers(), ldap_msg);
assert_true(NT_STATUS_IS_OK(status));
}
int main(_UNUSED_ int argc, _UNUSED_ const char **argv)
{
const struct CMUnitTest tests[] = {
@ -280,6 +319,10 @@ int main(_UNUSED_ int argc, _UNUSED_ const char **argv)
test_recursion_depth_greater_than_max,
setup,
teardown),
cmocka_unit_test_setup_teardown(
test_decode_exop_response,
setup,
teardown),
};
cmocka_set_message_output(CM_OUTPUT_SUBUNIT);

View File

@ -0,0 +1 @@
libcli.ldap.ldap_message.test_decode_exop_response\(none\)