use a talloc_reparent in a very ugly way
authorAndrew Tridgell <tridge@samba.org>
Wed, 1 Jul 2009 05:13:49 +0000 (15:13 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 1 Jul 2009 05:15:37 +0000 (15:15 +1000)
this works around some terrible use of talloc in the libnet code

source4/libnet/libnet_rpc.c

index 66e12d0da1464b7cef1f1a67ab42459f163f3f39..45244489280d979a0033d163978b94ae3f84cc77 100644 (file)
@@ -400,8 +400,17 @@ static NTSTATUS libnet_RpcConnectDC_recv(struct composite_context *c,
 
        status = composite_wait(c);
        if (NT_STATUS_IS_OK(status)) {
-               /* move connected rpc pipe between memory contexts */
-               r->out.dcerpc_pipe = talloc_steal(mem_ctx, s->r.out.dcerpc_pipe);
+               /* move connected rpc pipe between memory contexts 
+                  
+                  The use of talloc_reparent(talloc_parent(), ...) is
+                  bizarre, but it is needed because of the absolutely
+                  atrocious use of talloc in this code. We need to
+                  force the original parent to change, but finding
+                  the original parent is well nigh impossible at this
+                  point in the code (yes, I tried).
+                */
+               r->out.dcerpc_pipe = talloc_reparent(talloc_parent(s->r.out.dcerpc_pipe), 
+                                                    mem_ctx, s->r.out.dcerpc_pipe);
 
                /* reference created pipe structure to long-term libnet_context
                   so that it can be used by other api functions even after short-term