svn commit: samba r22980 - in branches/SAMBA_3_0_26/source/client: .
sfrench at samba.org
sfrench at samba.org
Thu May 17 22:31:43 GMT 2007
Author: sfrench
Date: 2007-05-17 22:31:41 +0000 (Thu, 17 May 2007)
New Revision: 22980
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22980
Log:
Add in misc frees that valgrind noticed for mount.cifs.c
Modified:
branches/SAMBA_3_0_26/source/client/mount.cifs.c
Changeset:
Modified: branches/SAMBA_3_0_26/source/client/mount.cifs.c
===================================================================
--- branches/SAMBA_3_0_26/source/client/mount.cifs.c 2007-05-17 22:28:28 UTC (rev 22979)
+++ branches/SAMBA_3_0_26/source/client/mount.cifs.c 2007-05-17 22:31:41 UTC (rev 22980)
@@ -618,6 +618,7 @@
nocopy:
data = next_keyword;
}
+ free(*optionsp);
*optionsp = out;
return 0;
}
@@ -879,8 +880,8 @@
char * ipaddr = NULL;
char * uuid = NULL;
char * mountpoint = NULL;
- char * options;
- char * resolved_path;
+ char * options = NULL;
+ char * resolved_path = NULL;
char * temp;
int rc;
int rsize = 0;
@@ -1076,12 +1077,15 @@
get_password_from_file(0, getenv("PASSWD_FILE"));
}
- if (orgoptions && parse_options(&orgoptions, &flags))
- return -1;
+ if (orgoptions && parse_options(&orgoptions, &flags)) {
+ rc = -1;
+ goto mount_exit;
+ }
ipaddr = parse_server(&share_name);
if((ipaddr == NULL) && (got_ip == 0)) {
printf("No ip address specified and hostname not found\n");
- return -1;
+ rc = -1;
+ goto mount_exit;
}
/* BB save off path and pop after mount returns? */
@@ -1095,17 +1099,20 @@
}
if(chdir(mountpoint)) {
printf("mount error: can not change directory into mount target %s\n",mountpoint);
- return -1;
+ rc = -1;
+ goto mount_exit;
}
if(stat (".", &statbuf)) {
printf("mount error: mount point %s does not exist\n",mountpoint);
- return -1;
+ rc = -1;
+ goto mount_exit;
}
if (S_ISDIR(statbuf.st_mode) == 0) {
printf("mount error: mount point %s is not a directory\n",mountpoint);
- return -1;
+ rc = -1;
+ goto mount_exit;
}
if((getuid() != 0) && (geteuid() == 0)) {
@@ -1151,6 +1158,8 @@
optlen += strlen(ipaddr) + 4;
if(mountpassword)
optlen += strlen(mountpassword) + 6;
+ if(options)
+ free(options);
options = (char *)malloc(optlen + 10 + 64 /* space for commas in password */ + 8 /* space for domain= , domain name itself was counted as part of the length username string above */);
if(options == NULL) {
@@ -1233,14 +1242,11 @@
}
}
default:
-
printf("mount error %d = %s\n",errno,strerror(errno));
}
printf("Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)\n");
- if(mountpassword) {
- memset(mountpassword,0,64);
- }
- return -1;
+ rc = -1;
+ goto mount_exit;
} else {
pmntfile = setmntent(MOUNTED, "a+");
if(pmntfile) {
@@ -1270,7 +1276,7 @@
strcat(mountent.mnt_opts,",user=");
strcat(mountent.mnt_opts,mount_user);
}
- free(mount_user);
+ /* free(mount_user); do not free static mem */
}
}
mountent.mnt_freq = 0;
@@ -1283,6 +1289,8 @@
printf("could not update mount table\n");
}
}
+ rc = 0;
+mount_exit:
if(mountpassword) {
int len = strlen(mountpassword);
memset(mountpassword,0,len);
@@ -1305,6 +1313,6 @@
if(free_share_name) {
free(share_name);
}
- return 0;
+ return rc;
}
More information about the samba-cvs
mailing list