diff options
| author | Eric Andersen <andersen@codepoet.org> | 2004-07-26 12:05:12 +0000 |
|---|---|---|
| committer | Eric Andersen <andersen@codepoet.org> | 2004-07-26 12:05:12 +0000 |
| commit | 882cec3e40af63d1866cab7b1ce322d70f94c7df (patch) | |
| tree | 3e4b67444ff26ab535ab703918f7337b14f69538 /util-linux | |
| parent | 29128cd4122c6f5edad767363615681bee1db04f (diff) | |
| download | busybox-w32-882cec3e40af63d1866cab7b1ce322d70f94c7df.tar.gz busybox-w32-882cec3e40af63d1866cab7b1ce322d70f94c7df.tar.bz2 busybox-w32-882cec3e40af63d1866cab7b1ce322d70f94c7df.zip | |
YAEGASHI Takeshi writes:
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.
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/nfsmount.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c index 34f23f5aa..0ebab80f6 100644 --- a/util-linux/nfsmount.c +++ b/util-linux/nfsmount.c | |||
| @@ -315,7 +315,7 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
| 315 | char new_opts[1024]; | 315 | char new_opts[1024]; |
| 316 | struct timeval total_timeout; | 316 | struct timeval total_timeout; |
| 317 | enum clnt_stat clnt_stat; | 317 | enum clnt_stat clnt_stat; |
| 318 | static struct nfs_mount_data data; | 318 | struct nfs_mount_data data; |
| 319 | char *opt, *opteq; | 319 | char *opt, *opteq; |
| 320 | int val; | 320 | int val; |
| 321 | struct hostent *hp; | 321 | struct hostent *hp; |
| @@ -602,10 +602,9 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
| 602 | #endif | 602 | #endif |
| 603 | 603 | ||
| 604 | data.version = nfs_mount_version; | 604 | data.version = nfs_mount_version; |
| 605 | *mount_opts = (char *) &data; | ||
| 606 | 605 | ||
| 607 | if (*flags & MS_REMOUNT) | 606 | if (*flags & MS_REMOUNT) |
| 608 | return 0; | 607 | goto copy_data_and_return; |
| 609 | 608 | ||
| 610 | /* | 609 | /* |
| 611 | * If the previous mount operation on the same host was | 610 | * If the previous mount operation on the same host was |
| @@ -857,6 +856,9 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
| 857 | auth_destroy(mclient->cl_auth); | 856 | auth_destroy(mclient->cl_auth); |
| 858 | clnt_destroy(mclient); | 857 | clnt_destroy(mclient); |
| 859 | close(msock); | 858 | close(msock); |
| 859 | copy_data_and_return: | ||
| 860 | *mount_opts = xrealloc(*mount_opts, sizeof(data)); | ||
| 861 | memcpy(*mount_opts, &data, sizeof(data)); | ||
| 860 | return 0; | 862 | return 0; |
| 861 | 863 | ||
| 862 | /* abort */ | 864 | /* abort */ |
