libnet_join

Andrew Bartlett abartlet at samba.org
Mon Sep 5 06:32:05 GMT 2005


On Mon, 2005-09-05 at 00:11 -0600, Brad Henry wrote:
> Andrew Bartlett wrote:
> 
> >On Sun, 2005-09-04 at 18:12 -0600, Brad Henry wrote:
> >  
> >
> >>Andrew Bartlett wrote:
> >>    
> >>
> >
> >  
> >
> >>I'm getting the hang of valgrind and gdb. I made this change, and this 
> >>patch also includes a fix for a problem valgrind found, with 
> >>libnet_Join_primary_domain() not passing a talloc()'d libnet_JoinDomain 
> >>struct to the libnet_JoinDomain() function.
> >>    
> >>
> >
> >It still doesn't look like you are doing a clean seperation between
> >parent and temporary memory contexts.  I don't mind if the rule to have
> >the 'r' structure be talloced is extended much further, if it results in
> >cleaner, more correct code.
> >
> >Andrew Bartlett
> >
> >  
> >
> Hi again,
> 
> These two patches should implement libnet_join using the local and 
> parent contexts correctly.

This looks much better.  I have just one comment, based on a change in
the 'pattern' that tridge has suggested, to avoid certain errors:

+       r->out.join_password = talloc_steal(r, password_str);
+       r->out.domain_sid = talloc_steal(r, domain_sid);
+       r->out.domain_name = talloc_steal(r, domain_name);
+       r->out.realm = talloc_steal(r, realm);
+       r->out.dcerpc_pipe = talloc_steal(r, dcerpc_pipe);
+       r->out.samr_pipe = talloc_steal(r, samr_pipe);
+       r->out.samr_binding = talloc_steal(r, samr_binding);
+       r->out.user_handle = talloc_steal(r, cu.out.user_handle);
+       r->out.error_string = talloc_steal(r,
r2.samr_handle.out.error_string);

The problem with talloc_steal is that it returns a void*.  Now, we have
been bitten by this, as it nicely kills some of the type-checking the
compiler can do for us.

As talloc_steal always returns the same pointer as it's input, it has
been suggested to me that we should do:

+ r->out.error_string = r2.samr_handle.out.error_string
+ talloc_steal(r, r2.samr_handle.out.error_string);

(ie, as two operations).  

Andrew Bartlett
-- 
Andrew Bartlett                                http://samba.org/~abartlet/
Samba Developer, SuSE Labs, Novell Inc.        http://suse.de
Authentication Developer, Samba Team           http://samba.org
Student Network Administrator, Hawker College  http://hawkerc.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20050905/77391495/attachment.bin


More information about the samba-technical mailing list