[BusyBox] [PATCH] mount -a -t nfs causes a segmentation fault
YAEGASHI Takeshi
t at keshi.org
Mon Jul 26 09:54:42 UTC 2004
Hi,
With the following /etc/fstab (any two or more lines of nfs), mount -a
-t nfs causes a segmentation faults.
server:/exports/aaa /mnt/aaa nfs defaults 0 0
server:/exprots/bbb /mnt/bbb nfs defaults 0 0
In util-linux/nfsmount.c, it overwrites malloc'ed pointer *mount_opts
with a static pointer. With this patch it does proper memory realloc
and data copy instead.
Index: util-linux/nfsmount.c
===================================================================
RCS file: /var/cvs/busybox/util-linux/nfsmount.c,v
retrieving revision 1.27
diff -u -r1.27 nfsmount.c
--- util-linux/nfsmount.c 15 Mar 2004 08:29:22 -0000 1.27
+++ util-linux/nfsmount.c 26 Jul 2004 08:39:23 -0000
@@ -315,7 +315,7 @@
char new_opts[1024];
struct timeval total_timeout;
enum clnt_stat clnt_stat;
- static struct nfs_mount_data data;
+ struct nfs_mount_data data;
char *opt, *opteq;
int val;
struct hostent *hp;
@@ -602,10 +602,9 @@
#endif
data.version = nfs_mount_version;
- *mount_opts = (char *) &data;
if (*flags & MS_REMOUNT)
- return 0;
+ goto copy_data_and_return;
/*
* If the previous mount operation on the same host was
@@ -857,6 +856,9 @@
auth_destroy(mclient->cl_auth);
clnt_destroy(mclient);
close(msock);
+copy_data_and_return:
+ *mount_opts = xrealloc(*mount_opts, sizeof(data));
+ memcpy(*mount_opts, &data, sizeof(data));
return 0;
/* abort */
Regards,
--
YAEGASHI Takeshi <t at keshi.org> <takeshi at yaegashi.jp>
More information about the busybox
mailing list