Bug 8345 - Did not initialize pointer before using it in vfs_hpuxacl.c file
Summary: Did not initialize pointer before using it in vfs_hpuxacl.c file
Status: NEW
Alias: None
Product: Samba 3.6
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: unspecified
Hardware: All HP-UX
: P5 normal
Target Milestone: ---
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-03 09:05 UTC by jinyunshuai
Modified: 2011-08-04 09:45 UTC (History)
0 users

See Also:


Attachments
Patch (1.05 KB, patch)
2011-08-03 18:20 UTC, Volker Lendecke
no flags Details
integrated patch (1.32 KB, text/plain)
2011-08-04 09:27 UTC, jinyunshuai
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description jinyunshuai 2011-08-03 09:05:09 UTC
Did not initialize pointer before using it, so that SAFE_FREE() won't free an
uninitialized pointer.
Comment 1 jinyunshuai 2011-08-03 09:54:59 UTC
I find vfs_hpuxacl.c file on the branch of v3-5-test still have the issue

please take a look at following codes:

int hpuxacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
				    const char *path)
{
	SMB_ACL_T smb_acl;           
	int ret = -1;
	HPUX_ACL_T hpux_acl;
	int count;

	DEBUG(10, ("entering hpuxacl_sys_acl_delete_def_file.\n"));
	
	smb_acl = hpuxacl_sys_acl_get_file(handle, path, 
					   SMB_ACL_TYPE_ACCESS);
	if (smb_acl == NULL) {
		DEBUG(10, ("getting file acl failed!\n"));
		goto done;
	}
	if (!smb_acl_to_hpux_acl(smb_acl, &hpux_acl, &count, 
				 SMB_ACL_TYPE_ACCESS))
	{
		DEBUG(10, ("conversion smb_acl -> hpux_acl failed.\n"));
		goto done;
	}
	if (!hpux_acl_sort(hpux_acl, count)) {
		DEBUG(10, ("resulting acl is not valid!\n"));
		goto done;
	}
	ret = acl(discard_const_p(char, path), ACL_SET, count, hpux_acl);
	if (ret != 0) {
		DEBUG(10, ("settinge file acl failed!\n"));
	}
	
 done:
	DEBUG(10, ("hpuxacl_sys_acl_delete_def_file %s.\n",
		   ((ret != 0) ? "failed" : "succeeded" )));
	SAFE_FREE(smb_acl);
	return ret;
}


I think smb_acl and  hpux_acl should need to initialize before using them. 

such as:

SMB_ACL_T smb_acl=NULL;
HPUX_ACL_T hpux_acl=NULL;


Do you think so?
Comment 2 Matthias Dieter Wallnöfer 2011-08-03 16:47:59 UTC
That is a Samba 3.X-specific issue.
Comment 3 Volker Lendecke 2011-08-03 18:20:17 UTC
Created attachment 6750 [details]
Patch

I fail to see the code path for smb_acl to remain uninitialized. The first instruction in the routine is an assignment to smb_acl. I do however see a memory leak for hpux_acl. Can you please describe the exact path to smb_acl to be used in an uninitialized way? And, can you review my patch? I don't have hpux readily available, so I can't really test this.

Thanks,

Volker
Comment 4 jinyunshuai 2011-08-04 09:27:05 UTC
Created attachment 6753 [details]
integrated patch

Hi Volker,

I have take a look at your patch, this is a part of we's modification. attachments is the integrated patch of vfs_hpuxacl.c file
Comment 5 Volker Lendecke 2011-08-04 09:34:51 UTC
Did you edit your .gitconfig according to 

http://wiki.samba.org/index.php/Using_Git_for_Samba_Development

using

$ git config --global user.email Your.Email@domain.com
$ git config --global user.name "Your Real Name"

? And, "/tmp/tmp.patch" is not very informative as a commit message. Samba convention says that normally we describe a bit what the patch does when doing the git commit.
Comment 6 jinyunshuai 2011-08-04 09:45:31 UTC
Thank you very much for your help


Kingson