summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source4/include/smb.h5
-rw-r--r--source4/ldap_server/ldap_server.c41
-rw-r--r--source4/ldap_server/ldap_server.h5
-rw-r--r--source4/rpc_server/dcerpc_server.c60
-rw-r--r--source4/rpc_server/dcerpc_server.h5
-rw-r--r--source4/rpc_server/dcerpc_sock.c1
-rw-r--r--source4/winbind/wb_server.c25
7 files changed, 71 insertions, 71 deletions
diff --git a/source4/include/smb.h b/source4/include/smb.h
index 3c03c7d7f1..fcde3848dc 100644
--- a/source4/include/smb.h
+++ b/source4/include/smb.h
@@ -192,6 +192,11 @@ typedef struct datablob {
size_t length;
} DATA_BLOB;
+struct data_blob_list_item {
+ struct data_blob_list_item *prev,*next;
+ DATA_BLOB blob;
+};
+
/* by making struct ldb_val and DATA_BLOB the same, we can simplify
a fair bit of code */
#define ldb_val datablob
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index c898471e27..4320a0ad5e 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -40,8 +40,10 @@
static void ldapsrv_terminate_connection(struct ldapsrv_connection *conn,
const char *reason)
{
- talloc_free(conn->tls);
- conn->tls = NULL;
+ if (conn->tls) {
+ talloc_free(conn->tls);
+ conn->tls = NULL;
+ }
stream_terminate_connection(conn->connection, reason);
}
@@ -54,7 +56,7 @@ static void ldapsrv_process_message(struct ldapsrv_connection *conn,
struct ldapsrv_call *call;
NTSTATUS status;
DATA_BLOB blob;
- struct ldapsrv_send *q;
+ struct data_blob_list_item *q;
BOOL enable_wrap = conn->enable_wrap;
call = talloc(conn, struct ldapsrv_call);
@@ -114,16 +116,16 @@ static void ldapsrv_process_message(struct ldapsrv_connection *conn,
data_blob_free(&wrapped);
}
- q = talloc(conn, struct ldapsrv_send);
+ q = talloc(conn, struct data_blob_list_item);
if (q == NULL) goto failed;
- q->data = blob;
+ q->blob = blob;
talloc_steal(q, blob.data);
if (conn->send_queue == NULL) {
EVENT_FD_WRITEABLE(conn->connection->event.fde);
}
- DLIST_ADD_END(conn->send_queue, q, struct ldapsrv_send *);
+ DLIST_ADD_END(conn->send_queue, q, struct data_blob_list_item *);
talloc_free(call);
return;
@@ -305,11 +307,11 @@ static void ldapsrv_send(struct stream_connection *c, uint16_t flags)
struct ldapsrv_connection *conn =
talloc_get_type(c->private, struct ldapsrv_connection);
while (conn->send_queue) {
- struct ldapsrv_send *q = conn->send_queue;
+ struct data_blob_list_item *q = conn->send_queue;
size_t nsent;
NTSTATUS status;
- status = tls_socket_send(conn->tls, &q->data, &nsent);
+ status = tls_socket_send(conn->tls, &q->blob, &nsent);
if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
break;
}
@@ -318,9 +320,9 @@ static void ldapsrv_send(struct stream_connection *c, uint16_t flags)
return;
}
- q->data.data += nsent;
- q->data.length -= nsent;
- if (q->data.length == 0) {
+ q->blob.data += nsent;
+ q->blob.length -= nsent;
+ if (q->blob.length == 0) {
DLIST_REMOVE(conn->send_queue, q);
}
}
@@ -341,13 +343,16 @@ static void ldapsrv_accept(struct stream_connection *c)
int port;
conn = talloc_zero(c, struct ldapsrv_connection);
- if (conn == NULL) goto failed;
+ if (!conn) {
+ stream_terminate_connection(c, "ldapsrv_accept: out of memory");
+ return;
+ }
conn->enable_wrap = False;
conn->partial = data_blob(NULL, 0);
conn->send_queue = NULL;
conn->connection = c;
- conn->service = talloc_get_type(c->private, struct ldapsrv_service);
+ conn->service = ldapsrv_service;
conn->processing = False;
c->private = conn;
@@ -357,14 +362,12 @@ static void ldapsrv_accept(struct stream_connection *c)
any ldap connection */
conn->tls = tls_init_server(ldapsrv_service->tls_params, c->socket,
c->event.fde, NULL, port != 389);
- if (conn->tls == NULL) goto failed;
+ if (!conn->tls) {
+ ldapsrv_terminate_connection(c, "ldapsrv_accept: tls_init_server() failed");
+ return;
+ }
irpc_add_name(c->msg_ctx, "ldap_server");
-
- return;
-
-failed:
- talloc_free(c);
}
static const struct stream_server_ops ldap_stream_ops = {
diff --git a/source4/ldap_server/ldap_server.h b/source4/ldap_server/ldap_server.h
index e3031d0177..a1981843a6 100644
--- a/source4/ldap_server/ldap_server.h
+++ b/source4/ldap_server/ldap_server.h
@@ -35,10 +35,7 @@ struct ldapsrv_connection {
BOOL enable_wrap;
/* reply send queue */
- struct ldapsrv_send {
- struct ldapsrv_send *next, *prev;
- DATA_BLOB data;
- } *send_queue;
+ struct data_blob_list_item *send_queue;
BOOL processing;
};
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index d1ee53b538..a00d697520 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -385,7 +385,7 @@ static void dcesrv_init_hdr(struct ncacn_packet *pkt)
static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code)
{
struct ncacn_packet pkt;
- struct dcesrv_call_reply *rep;
+ struct data_blob_list_item *rep;
NTSTATUS status;
/* setup a bind_ack */
@@ -399,19 +399,19 @@ static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code
pkt.u.fault.cancel_count = 0;
pkt.u.fault.status = fault_code;
- rep = talloc(call, struct dcesrv_call_reply);
+ rep = talloc(call, struct data_blob_list_item);
if (!rep) {
return NT_STATUS_NO_MEMORY;
}
- status = ncacn_push_auth(&rep->data, call, &pkt, NULL);
+ status = ncacn_push_auth(&rep->blob, call, &pkt, NULL);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- dcerpc_set_frag_length(&rep->data, rep->data.length);
+ dcerpc_set_frag_length(&rep->blob, rep->blob.length);
- DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
+ DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
return NT_STATUS_OK;
@@ -424,7 +424,7 @@ static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code
static NTSTATUS dcesrv_bind_nak(struct dcesrv_call_state *call, uint32_t reason)
{
struct ncacn_packet pkt;
- struct dcesrv_call_reply *rep;
+ struct data_blob_list_item *rep;
NTSTATUS status;
/* setup a bind_nak */
@@ -436,19 +436,19 @@ static NTSTATUS dcesrv_bind_nak(struct dcesrv_call_state *call, uint32_t reason)
pkt.u.bind_nak.reject_reason = reason;
pkt.u.bind_nak.num_versions = 0;
- rep = talloc(call, struct dcesrv_call_reply);
+ rep = talloc(call, struct data_blob_list_item);
if (!rep) {
return NT_STATUS_NO_MEMORY;
}
- status = ncacn_push_auth(&rep->data, call, &pkt, NULL);
+ status = ncacn_push_auth(&rep->blob, call, &pkt, NULL);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- dcerpc_set_frag_length(&rep->data, rep->data.length);
+ dcerpc_set_frag_length(&rep->blob, rep->blob.length);
- DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
+ DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
return NT_STATUS_OK;
@@ -463,7 +463,7 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
const char *uuid, *transfer_syntax;
uint32_t if_version, transfer_syntax_version;
struct ncacn_packet pkt;
- struct dcesrv_call_reply *rep;
+ struct data_blob_list_item *rep;
NTSTATUS status;
uint32_t result=0, reason=0;
uint32_t context_id;
@@ -571,20 +571,20 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
}
}
- rep = talloc(call, struct dcesrv_call_reply);
+ rep = talloc(call, struct data_blob_list_item);
if (!rep) {
return NT_STATUS_NO_MEMORY;
}
- status = ncacn_push_auth(&rep->data, call, &pkt,
+ status = ncacn_push_auth(&rep->blob, call, &pkt,
call->conn->auth_state.auth_info);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- dcerpc_set_frag_length(&rep->data, rep->data.length);
+ dcerpc_set_frag_length(&rep->blob, rep->blob.length);
- DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
+ DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
return NT_STATUS_OK;
@@ -664,7 +664,7 @@ static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_
static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call)
{
struct ncacn_packet pkt;
- struct dcesrv_call_reply *rep;
+ struct data_blob_list_item *rep;
NTSTATUS status;
uint32_t result=0, reason=0;
uint32_t context_id;
@@ -713,20 +713,20 @@ static NTSTATUS dcesrv_alter(struct dcesrv_call_state *call)
return dcesrv_bind_nak(call, 0);
}
- rep = talloc(call, struct dcesrv_call_reply);
+ rep = talloc(call, struct data_blob_list_item);
if (!rep) {
return NT_STATUS_NO_MEMORY;
}
- status = ncacn_push_auth(&rep->data, call, &pkt,
+ status = ncacn_push_auth(&rep->blob, call, &pkt,
call->conn->auth_state.auth_info);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- dcerpc_set_frag_length(&rep->data, rep->data.length);
+ dcerpc_set_frag_length(&rep->blob, rep->blob.length);
- DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
+ DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
DLIST_ADD_END(call->conn->call_list, call, struct dcesrv_call_state *);
return NT_STATUS_OK;
@@ -843,10 +843,10 @@ NTSTATUS dcesrv_reply(struct dcesrv_call_state *call)
do {
uint32_t length;
- struct dcesrv_call_reply *rep;
+ struct data_blob_list_item *rep;
struct ncacn_packet pkt;
- rep = talloc(call, struct dcesrv_call_reply);
+ rep = talloc(call, struct data_blob_list_item);
NT_STATUS_HAVE_NO_MEMORY(rep);
length = stub.length;
@@ -874,13 +874,13 @@ NTSTATUS dcesrv_reply(struct dcesrv_call_state *call)
pkt.u.response.stub_and_verifier.data = stub.data;
pkt.u.response.stub_and_verifier.length = length;
- if (!dcesrv_auth_response(call, &rep->data, &pkt)) {
+ if (!dcesrv_auth_response(call, &rep->blob, &pkt)) {
return dcesrv_fault(call, DCERPC_FAULT_OTHER);
}
- dcerpc_set_frag_length(&rep->data, rep->data.length);
+ dcerpc_set_frag_length(&rep->blob, rep->blob.length);
- DLIST_ADD_END(call->replies, rep, struct dcesrv_call_reply *);
+ DLIST_ADD_END(call->replies, rep, struct data_blob_list_item *);
stub.data += length;
stub.length -= length;
@@ -1116,7 +1116,7 @@ NTSTATUS dcesrv_output(struct dcesrv_connection *dce_conn,
{
NTSTATUS status;
struct dcesrv_call_state *call;
- struct dcesrv_call_reply *rep;
+ struct data_blob_list_item *rep;
size_t nwritten;
call = dce_conn->call_list;
@@ -1132,13 +1132,13 @@ NTSTATUS dcesrv_output(struct dcesrv_connection *dce_conn,
}
rep = call->replies;
- status = write_fn(private_data, &rep->data, &nwritten);
+ status = write_fn(private_data, &rep->blob, &nwritten);
NT_STATUS_IS_ERR_RETURN(status);
- rep->data.length -= nwritten;
- rep->data.data += nwritten;
+ rep->blob.length -= nwritten;
+ rep->blob.data += nwritten;
- if (rep->data.length == 0) {
+ if (rep->blob.length == 0) {
/* we're done with this section of the call */
DLIST_REMOVE(call->replies, rep);
}
diff --git a/source4/rpc_server/dcerpc_server.h b/source4/rpc_server/dcerpc_server.h
index 3c4888784d..9b82b2edcc 100644
--- a/source4/rpc_server/dcerpc_server.h
+++ b/source4/rpc_server/dcerpc_server.h
@@ -102,10 +102,7 @@ struct dcesrv_call_state {
DATA_BLOB input;
- struct dcesrv_call_reply {
- struct dcesrv_call_reply *next, *prev;
- DATA_BLOB data;
- } *replies;
+ struct data_blob_list_item *replies;
/* this is used by the boilerplate code to generate DCERPC faults */
uint32_t fault_code;
diff --git a/source4/rpc_server/dcerpc_sock.c b/source4/rpc_server/dcerpc_sock.c
index cf3ce3cf7e..207813abfc 100644
--- a/source4/rpc_server/dcerpc_sock.c
+++ b/source4/rpc_server/dcerpc_sock.c
@@ -73,6 +73,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("dcesrv_sock_accept: dcesrv_endpoint_connect failed: %s\n",
nt_errstr(status)));
+ stream_terminate_connection(srv_conn, nt_errstr(status));
return;
}
diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c
index 375c88c72a..e35651c6e5 100644
--- a/source4/winbind/wb_server.c
+++ b/source4/winbind/wb_server.c
@@ -39,11 +39,8 @@
state of an open winbind connection
*/
struct wbserver_connection {
- DATA_BLOB blob;
- struct send_queue {
- struct send_queue *next, *prev;
- DATA_BLOB blob;
- } *queue;
+ DATA_BLOB input;
+ struct data_blob_list_item *send_queue;
};
@@ -55,7 +52,7 @@ static void winbind_accept(struct stream_connection *conn)
struct wbserver_connection *wbconn;
wbconn = talloc_zero(conn, struct wbserver_connection);
- wbconn->blob = data_blob_talloc(wbconn, NULL, 1024);
+ wbconn->input = data_blob_talloc(wbconn, NULL, 1024);
conn->private = wbconn;
}
@@ -68,9 +65,9 @@ static void winbind_recv(struct stream_connection *conn, uint16_t flags)
struct wbserver_connection *wbconn = talloc_get_type(conn->private, struct wbserver_connection);
NTSTATUS status;
size_t nread;
- struct send_queue *q;
+ struct data_blob_list_item *q;
- status = socket_recv(conn->socket, wbconn->blob.data, wbconn->blob.length, &nread, 0);
+ status = socket_recv(conn->socket, wbconn->input.data, wbconn->input.length, &nread, 0);
if (NT_STATUS_IS_ERR(status)) {
DEBUG(10,("socket_recv: %s\n",nt_errstr(status)));
stream_terminate_connection(conn, "socket_recv: failed\n");
@@ -78,19 +75,19 @@ static void winbind_recv(struct stream_connection *conn, uint16_t flags)
}
/* just reflect the data back down the socket */
- q = talloc(wbconn, struct send_queue);
+ q = talloc(wbconn, struct data_blob_list_item);
if (q == NULL) {
stream_terminate_connection(conn, "winbind_recv: out of memory\n");
return;
}
- q->blob = data_blob_talloc(q, wbconn->blob.data, nread);
+ q->blob = data_blob_talloc(q, wbconn->input.data, nread);
if (q->blob.data == NULL) {
stream_terminate_connection(conn, "winbind_recv: out of memory\n");
return;
}
- DLIST_ADD_END(wbconn->queue, q, struct send_queue *);
+ DLIST_ADD_END(wbconn->send_queue, q, struct data_blob_list_item *);
EVENT_FD_WRITEABLE(conn->event.fde);
}
@@ -102,8 +99,8 @@ static void winbind_send(struct stream_connection *conn, uint16_t flags)
{
struct wbserver_connection *wbconn = talloc_get_type(conn->private, struct wbserver_connection);
- while (wbconn->queue) {
- struct send_queue *q = wbconn->queue;
+ while (wbconn->send_queue) {
+ struct data_blob_list_item *q = wbconn->send_queue;
NTSTATUS status;
size_t sendlen;
@@ -121,7 +118,7 @@ static void winbind_send(struct stream_connection *conn, uint16_t flags)
q->blob.data += sendlen;
if (q->blob.length == 0) {
- DLIST_REMOVE(wbconn->queue, q);
+ DLIST_REMOVE(wbconn->send_queue, q);
talloc_free(q);
}
}