svn commit: samba r15858 - in branches/SAMBA_4_0/source/libnet: .

metze at samba.org metze at samba.org
Wed May 24 11:46:19 GMT 2006


Author: metze
Date: 2006-05-24 11:46:19 +0000 (Wed, 24 May 2006)
New Revision: 15858

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15858

Log:
- initialize s->r.out
- don't check for mem_ctx, ctx and r, we should crash when they're wrong
  as it's a programmer error!
- pass the error string to the caller

metze
Modified:
   branches/SAMBA_4_0/source/libnet/libnet_rpc.c


Changeset:
Modified: branches/SAMBA_4_0/source/libnet/libnet_rpc.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_rpc.c	2006-05-24 11:32:17 UTC (rev 15857)
+++ branches/SAMBA_4_0/source/libnet/libnet_rpc.c	2006-05-24 11:46:19 UTC (rev 15858)
@@ -65,6 +65,7 @@
 	c->event_ctx = ctx->event_ctx;
 
 	s->r = *r;
+	ZERO_STRUCT(s->r.out);
 
 	/* prepare binding string */
 	switch (r->level) {
@@ -131,10 +132,12 @@
 					  TALLOC_CTX *mem_ctx,
 					  struct libnet_RpcConnect *r)
 {
-	struct rpc_connect_srv_state *s;
-	NTSTATUS status = composite_wait(c);
+	NTSTATUS status;
+	struct rpc_connect_srv_state *s = talloc_get_type(c->private_data,
+					  struct rpc_connect_srv_state);
 
-	if (NT_STATUS_IS_OK(status) && ctx && mem_ctx && r) {
+	status = composite_wait(c);
+	if (NT_STATUS_IS_OK(status)) {
 		/* move the returned rpc pipe between memory contexts */
 		s = talloc_get_type(c->private_data, struct rpc_connect_srv_state);
 		r->out.dcerpc_pipe = talloc_steal(mem_ctx, s->r.out.dcerpc_pipe);
@@ -147,6 +150,8 @@
 		} else {
 			ctx->pipe = talloc_reference(ctx, r->out.dcerpc_pipe);
 		}
+	} else {
+		r->out.error_string = talloc_steal(mem_ctx, s->r.out.error_string);
 	}
 
 	talloc_free(c);
@@ -195,8 +200,9 @@
 	c->private_data = s;
 	c->event_ctx = ctx->event_ctx;
 
+	s->ctx = ctx;
 	s->r   = *r;
-	s->ctx = ctx;
+	ZERO_STRUCT(s->r.out);
 
 	switch (r->level) {
 	case LIBNET_RPC_CONNECT_PDC:
@@ -302,13 +308,12 @@
 					 struct libnet_RpcConnect *r)
 {
 	NTSTATUS status;
-	struct rpc_connect_dc_state *s;
-	
+	struct rpc_connect_dc_state *s = talloc_get_type(c->private_data,
+					 struct rpc_connect_dc_state);
+
 	status = composite_wait(c);
-
-	if (NT_STATUS_IS_OK(status) && ctx && mem_ctx && r) {
+	if (NT_STATUS_IS_OK(status)) {
 		/* move connected rpc pipe between memory contexts */
-		s = talloc_get_type(c->private_data, struct rpc_connect_dc_state);
 		r->out.dcerpc_pipe = talloc_steal(mem_ctx, s->r.out.dcerpc_pipe);
 
 		/* reference created pipe structure to long-term libnet_context
@@ -319,6 +324,8 @@
 		} else {
 			ctx->pipe = talloc_reference(ctx, r->out.dcerpc_pipe);
 		}
+	} else {
+		r->out.error_string = talloc_steal(mem_ctx, s->r.out.error_string);
 	}
 
 	talloc_free(c);
@@ -379,8 +386,9 @@
 	c->private_data = s;
 	c->event_ctx = ctx->event_ctx;
 
+	s->ctx = ctx;
 	s->r   = *r;
-	s->ctx = ctx;
+	ZERO_STRUCT(s->r.out);
 
 	/* proceed to pure rpc connection if the binding string is provided,
 	   otherwise try to connect domain controller */
@@ -646,12 +654,11 @@
 					     TALLOC_CTX *mem_ctx, struct libnet_RpcConnect *r)
 {
 	NTSTATUS status;
-	struct rpc_connect_dci_state *s;
+	struct rpc_connect_dci_state *s = talloc_get_type(c->private_data,
+					  struct rpc_connect_dci_state);
 
 	status = composite_wait(c);
 	if (NT_STATUS_IS_OK(status)) {
-		s = talloc_get_type(c->private_data, struct rpc_connect_dci_state);
-
 		r->out.realm        = talloc_steal(mem_ctx, s->r.out.realm);
 		r->out.guid         = talloc_steal(mem_ctx, s->r.out.guid);
 		r->out.domain_name  = talloc_steal(mem_ctx, s->r.out.domain_name);
@@ -667,6 +674,8 @@
 		} else {
 			ctx->pipe = talloc_reference(ctx, r->out.dcerpc_pipe);
 		}
+	} else {
+		r->out.error_string = talloc_steal(mem_ctx, s->r.out.error_string);
 	}
 
 	talloc_free(c);
@@ -740,6 +749,7 @@
 		return libnet_RpcConnectDCInfo_recv(c, ctx, mem_ctx, r);
 
 	default:
+		ZERO_STRUCT(r->out);
 		return NT_STATUS_INVALID_LEVEL;
 	}
 }



More information about the samba-cvs mailing list