Bug 6817 - Calling talloc_asprintf and talloc_strdup with wrong argument
Calling talloc_asprintf and talloc_strdup with wrong argument
Status: RESOLVED INVALID
Product: Samba 3.4
Classification: Unclassified
Component: Ntlm_auth Tool
3.4.2
Other Linux
: P3 major
: ---
Assigned To: Andrew Bartlett
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-10-15 13:16 UTC by James Ding
Modified: 2009-10-15 18:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Ding 2009-10-15 13:16:22 UTC
*mem_ctx is removed from struct ntlmssp_state already, but in ntlm_auth.c, some code is still using it as talloc_ funcations' argument. Same errors also in source3/libsmb/ntlmssp.c



In ntlm_auth.c

line 550:
		ntlmssp_state->auth_context = talloc_strdup(ntlmssp_state,
							    unix_name);

line 584:
		ntlmssp_state->auth_context = talloc_asprintf(ntlmssp_state,
							      "%s%c%s", ntlmssp_state->domain, 
							      *lp_winbind_separator(), 
							      ntlmssp_state->user);


==================
Fix:

550:
ntlmssp_state->auth_context = talloc_strdup(talloc_tos(),
							    unix_name);


Fix:line 584:
		ntlmssp_state->auth_context = talloc_asprintf(ntltalloc_tos(),
							      "%s%c%s", ntlmssp_state->domain, 
							      *lp_winbind_separator(), 
							      ntlmssp_state->user);
Comment 1 Andrew Bartlett 2009-10-15 16:54:54 UTC
I fail to see the problem.  ntlmssp_state itself is a talloc context is it not?

What errors do you get?
Comment 2 James Ding 2009-10-15 17:43:04 UTC
(In reply to comment #1)
> I fail to see the problem.  ntlmssp_state itself is a talloc context is it not?
> 
> What errors do you get?
> 

I did not dig into talloc_* function, just feel bad from the header file difference:
<<<<<<<<<<<<<<<<<<<<<<<<
3.2.*  include/ntlmssp.h
typedef struct ntlmssp_state 
{
	TALLOC_CTX *mem_ctx;
	unsigned int ref_count;
	enum NTLMSSP_ROLE role;
>>>>>>>>>>>>>>>>>>>>>>>>
3.4.* include/ntlmssp.h
typedef struct ntlmssp_state 
{
	unsigned int ref_count;
	enum NTLMSSP_ROLE role;
=======================

mem_ctx in not in the structure anymore. Sorry I don't know if ntlmssp_state itself is a talloc context or not.
Comment 3 Andrew Bartlett 2009-10-15 17:46:59 UTC
This isn't a bug.  A read of talloc_guide.txt in lib/talloc might be worthwhile. 
Comment 4 James Ding 2009-10-15 18:01:13 UTC
(In reply to comment #3)
> This isn't a bug.  A read of talloc_guide.txt in lib/talloc might be
> worthwhile. 
> 

Thanks much. talloc_guide.txt does help.