From 4d1088faea8802af588218c98ae34e1700245806 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 21 Sep 2016 14:24:45 -0700 Subject: [PATCH] libcli/util: add struct tstream_context to tstream_read_pdu_blob_full_fn_t Add struct tstream_context to tstream_read_pdu_blob_full_fn_t and update all callers of tstream_read_pdu_blob_send() to use the correct callback. Signed-off-by: Ralph Boehme Reviewed-by: Andrew Bartlett --- libcli/ldap/ldap_message.c | 5 ++++- libcli/ldap/ldap_message.h | 6 +++++- libcli/util/tstream.c | 3 ++- libcli/util/tstream.h | 5 ++++- source4/dns_server/dns_server.c | 8 ++++---- source4/kdc/kdc-proxy.c | 2 +- source4/kdc/kdc-server.c | 12 ++++++------ source4/ldap_server/ldap_server.c | 4 +++- source4/libcli/wrepl/winsrepl.c | 2 +- source4/ntp_signd/ntp_signd.c | 8 ++++---- source4/torture/ntp/ntp_signd.c | 2 +- source4/wrepl_server/wrepl_in_connection.c | 10 +++++----- 12 files changed, 40 insertions(+), 27 deletions(-) diff --git a/libcli/ldap/ldap_message.c b/libcli/ldap/ldap_message.c index 3099086b05b..1a537e8144c 100644 --- a/libcli/ldap/ldap_message.c +++ b/libcli/ldap/ldap_message.c @@ -1650,7 +1650,10 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, return NT_STATUS_OK if a blob has enough bytes in it to be a full ldap packet. Set packet_size if true. */ -NTSTATUS ldap_full_packet(void *private_data, DATA_BLOB blob, size_t *packet_size) +NTSTATUS ldap_full_packet(struct tstream_context *stream, + void *private_data, + DATA_BLOB blob, + size_t *packet_size) { int ret; diff --git a/libcli/ldap/ldap_message.h b/libcli/ldap/ldap_message.h index 19bfb99ac97..dcbd1e97d84 100644 --- a/libcli/ldap/ldap_message.h +++ b/libcli/ldap/ldap_message.h @@ -218,6 +218,7 @@ struct ldap_request_limits { }; struct asn1_data; +struct tstream_context; struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx); NTSTATUS ldap_decode(struct asn1_data *data, @@ -227,7 +228,10 @@ NTSTATUS ldap_decode(struct asn1_data *data, bool ldap_encode(struct ldap_message *msg, const struct ldap_control_handler *control_handlers, DATA_BLOB *result, TALLOC_CTX *mem_ctx); -NTSTATUS ldap_full_packet(void *private_data, DATA_BLOB blob, size_t *packet_size); +NTSTATUS ldap_full_packet(struct tstream_context *stream, + void *private_data, + DATA_BLOB blob, + size_t *packet_size); bool asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx, struct asn1_data *data, diff --git a/libcli/util/tstream.c b/libcli/util/tstream.c index b4317f23ade..95e31cab34a 100644 --- a/libcli/util/tstream.c +++ b/libcli/util/tstream.c @@ -111,7 +111,8 @@ static void tstream_read_pdu_blob_done(struct tevent_req *subreq) return; } - status = state->caller.full_fn(state->caller.full_private, + status = state->caller.full_fn(state->caller.stream, + state->caller.full_private, state->pdu_blob, &pdu_size); if (NT_STATUS_IS_OK(status)) { tevent_req_done(req); diff --git a/libcli/util/tstream.h b/libcli/util/tstream.h index 6d30e04c70a..cf66abe942b 100644 --- a/libcli/util/tstream.h +++ b/libcli/util/tstream.h @@ -23,6 +23,8 @@ /** * @brief The function which will report the size of the full pdu. * + * @param[in] stream The tstream_context to operate on + * * @param[in] private_data Some private data which could be used. * * @param[in] blob The received blob to get the size from. @@ -32,7 +34,8 @@ * @return NT_STATUS_OK on success, STATUS_MORE_ENTRIES if there * are more entries. */ -typedef NTSTATUS tstream_read_pdu_blob_full_fn_t(void *private_data, +typedef NTSTATUS tstream_read_pdu_blob_full_fn_t(struct tstream_context *stream, + void *private_data, DATA_BLOB blob, size_t *packet_size); diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c index dd9916770a5..0a36c1c29e2 100644 --- a/source4/dns_server/dns_server.c +++ b/source4/dns_server/dns_server.c @@ -374,13 +374,13 @@ static void dns_tcp_call_loop(struct tevent_req *subreq) /* * The dns tcp pdu's has the length as 2 byte (initial_read_size), - * packet_full_request_u16 provides the pdu length then. + * tstream_full_request_u16 provides the pdu length then. */ subreq = tstream_read_pdu_blob_send(dns_conn, dns_conn->conn->event.ctx, dns_conn->tstream, 2, /* initial_read_size */ - packet_full_request_u16, + tstream_full_request_u16, dns_conn); if (subreq == NULL) { dns_tcp_terminate_connection(dns_conn, "dns_tcp_call_loop: " @@ -500,13 +500,13 @@ static void dns_tcp_accept(struct stream_connection *conn) /* * The dns tcp pdu's has the length as 2 byte (initial_read_size), - * packet_full_request_u16 provides the pdu length then. + * tstream_full_request_u16 provides the pdu length then. */ subreq = tstream_read_pdu_blob_send(dns_conn, dns_conn->conn->event.ctx, dns_conn->tstream, 2, /* initial_read_size */ - packet_full_request_u16, + tstream_full_request_u16, dns_conn); if (subreq == NULL) { dns_tcp_terminate_connection(dns_conn, "dns_tcp_accept: " diff --git a/source4/kdc/kdc-proxy.c b/source4/kdc/kdc-proxy.c index 2b63b071d6b..83d552a85a0 100644 --- a/source4/kdc/kdc-proxy.c +++ b/source4/kdc/kdc-proxy.c @@ -516,7 +516,7 @@ static void kdc_tcp_proxy_connect_done(struct tevent_req *subreq) state->ev, state->proxy.stream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, req); if (tevent_req_nomem(subreq, req)) { return; diff --git a/source4/kdc/kdc-server.c b/source4/kdc/kdc-server.c index ba56f04e71b..297d91e2716 100644 --- a/source4/kdc/kdc-server.c +++ b/source4/kdc/kdc-server.c @@ -349,13 +349,13 @@ static void kdc_tcp_call_loop(struct tevent_req *subreq) /* * The krb5 tcp pdu's has the length as 4 byte (initial_read_size), - * packet_full_request_u32 provides the pdu length then. + * tstream_full_request_u32 provides the pdu length then. */ subreq = tstream_read_pdu_blob_send(kdc_conn, kdc_conn->conn->event.ctx, kdc_conn->tstream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, kdc_conn); if (subreq == NULL) { kdc_tcp_terminate_connection(kdc_conn, "kdc_tcp_call_loop: " @@ -416,13 +416,13 @@ static void kdc_tcp_call_proxy_done(struct tevent_req *subreq) /* * The krb5 tcp pdu's has the length as 4 byte (initial_read_size), - * packet_full_request_u32 provides the pdu length then. + * tstream_full_request_u32 provides the pdu length then. */ subreq = tstream_read_pdu_blob_send(kdc_conn, kdc_conn->conn->event.ctx, kdc_conn->tstream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, kdc_conn); if (subreq == NULL) { kdc_tcp_terminate_connection(kdc_conn, "kdc_tcp_call_proxy_done: " @@ -505,13 +505,13 @@ static void kdc_tcp_accept(struct stream_connection *conn) /* * The krb5 tcp pdu's has the length as 4 byte (initial_read_size), - * packet_full_request_u32 provides the pdu length then. + * tstream_full_request_u32 provides the pdu length then. */ subreq = tstream_read_pdu_blob_send(kdc_conn, kdc_conn->conn->event.ctx, kdc_conn->tstream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, kdc_conn); if (subreq == NULL) { kdc_tcp_terminate_connection(kdc_conn, "kdc_tcp_accept: " diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c index 08acffc7d44..9c34c3e5712 100644 --- a/source4/ldap_server/ldap_server.c +++ b/source4/ldap_server/ldap_server.c @@ -449,6 +449,7 @@ static void ldapsrv_accept_tls_done(struct tevent_req *subreq) static void ldapsrv_call_read_done(struct tevent_req *subreq); static NTSTATUS ldapsrv_packet_check( + struct tstream_context *stream, void *private_data, DATA_BLOB blob, size_t *packet_size); @@ -1660,6 +1661,7 @@ static int ldapsrv_check_packet_size( * */ static NTSTATUS ldapsrv_packet_check( + struct tstream_context *stream, void *private_data, DATA_BLOB blob, size_t *packet_size) @@ -1668,7 +1670,7 @@ static NTSTATUS ldapsrv_packet_check( struct ldapsrv_connection *conn = private_data; int result = LDB_SUCCESS; - ret = ldap_full_packet(private_data, blob, packet_size); + ret = ldap_full_packet(stream, private_data, blob, packet_size); if (!NT_STATUS_IS_OK(ret)) { return ret; } diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c index 001363dd239..cf6c1f16d65 100644 --- a/source4/libcli/wrepl/winsrepl.c +++ b/source4/libcli/wrepl/winsrepl.c @@ -476,7 +476,7 @@ static void wrepl_request_writev_done(struct tevent_req *subreq) state->caller.ev, state->caller.wrepl_socket->stream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, NULL); if (tevent_req_nomem(subreq, req)) { return; diff --git a/source4/ntp_signd/ntp_signd.c b/source4/ntp_signd/ntp_signd.c index 4cf460fd2d9..e7ceba0f8a0 100644 --- a/source4/ntp_signd/ntp_signd.c +++ b/source4/ntp_signd/ntp_signd.c @@ -398,13 +398,13 @@ static void ntp_signd_call_loop(struct tevent_req *subreq) /* * The NTP tcp pdu's has the length as 4 byte (initial_read_size), - * packet_full_request_u32 provides the pdu length then. + * tstream_full_request_u32 provides the pdu length then. */ subreq = tstream_read_pdu_blob_send(ntp_signd_conn, ntp_signd_conn->conn->event.ctx, ntp_signd_conn->tstream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, ntp_signd_conn); if (subreq == NULL) { ntp_signd_terminate_connection(ntp_signd_conn, "ntp_signd_call_loop: " @@ -488,13 +488,13 @@ static void ntp_signd_accept(struct stream_connection *conn) /* * The NTP tcp pdu's has the length as 4 byte (initial_read_size), - * packet_full_request_u32 provides the pdu length then. + * tstream_full_request_u32 provides the pdu length then. */ subreq = tstream_read_pdu_blob_send(ntp_signd_conn, ntp_signd_conn->conn->event.ctx, ntp_signd_conn->tstream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, ntp_signd_conn); if (subreq == NULL) { ntp_signd_terminate_connection(ntp_signd_conn, diff --git a/source4/torture/ntp/ntp_signd.c b/source4/torture/ntp/ntp_signd.c index 6d482bfdee1..fd7da67c551 100644 --- a/source4/torture/ntp/ntp_signd.c +++ b/source4/torture/ntp/ntp_signd.c @@ -226,7 +226,7 @@ static bool test_ntp_signd(struct torture_context *tctx, tctx->ev, signd_client->tstream, 4, /*initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, NULL); torture_assert(tctx, req != NULL, "Failed to setup a read for pdu_blob."); diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c index 1cdc40968e2..571d65dde54 100644 --- a/source4/wrepl_server/wrepl_in_connection.c +++ b/source4/wrepl_server/wrepl_in_connection.c @@ -161,13 +161,13 @@ static void wreplsrv_accept(struct stream_connection *conn) /* * The wrepl pdu's has the length as 4 byte (initial_read_size), - * packet_full_request_u32 provides the pdu length then. + * tstream_full_request_u32 provides the pdu length then. */ subreq = tstream_read_pdu_blob_send(wrepl_conn, wrepl_conn->conn->event.ctx, wrepl_conn->tstream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, wrepl_conn); if (subreq == NULL) { wreplsrv_terminate_in_connection(wrepl_conn, "wrepl_accept: " @@ -269,7 +269,7 @@ noreply: wrepl_conn->conn->event.ctx, wrepl_conn->tstream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, wrepl_conn); if (subreq == NULL) { wreplsrv_terminate_in_connection(wrepl_conn, "wreplsrv_call_loop: " @@ -395,13 +395,13 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner, /* * The wrepl pdu's has the length as 4 byte (initial_read_size), - * packet_full_request_u32 provides the pdu length then. + * tstream_full_request_u32 provides the pdu length then. */ subreq = tstream_read_pdu_blob_send(wrepl_in, wrepl_in->conn->event.ctx, wrepl_in->tstream, 4, /* initial_read_size */ - packet_full_request_u32, + tstream_full_request_u32, wrepl_in); if (subreq == NULL) { wreplsrv_terminate_in_connection(wrepl_in, "wreplsrv_in_connection_merge: " -- 2.47.3