NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/40634: dostatvfs() broken when chroot to /
The following reply was made to PR kern/40634; it has been noted by GNATS.
From: enami tsugutomo <enami%sm.sony.co.jp@localhost>
To: bad%bsd.de@localhost
Cc: gnats-bugs%NetBSD.org@localhost
Subject: Re: kern/40634: dostatvfs() broken when chroot to /
Date: Sat, 14 Feb 2009 15:43:04 +0900 (JST)
> >Fix:
> Apply the following change to dostatvfs():
>
> * data.
> */
> if (strncmp(bp, sp->f_mntonname, len) == 0 &&
> - ((c = sp->f_mntonname[len]) == '/' || c == '\0')) {
> + (len <= 1 || (c = sp->f_mntonname[len]) == '/' || c ==
> '\0')) {
> (void)strlcpy(sp->f_mntonname, &sp->f_mntonname[len],
> sizeof(sp->f_mntonname));
> if (sp->f_mntonname[0] == '\0')
>
> when the chroot dir is / len is 1 and bp is "/" f_mnttonname[1] is uneqal
> to '/' and '\0' for all mount points other than /.
Your change removes / in front of mount point, doesn't it?
enami.
Index: vfs_syscalls.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.385
diff -u -r1.385 vfs_syscalls.c
--- vfs_syscalls.c 5 Feb 2009 13:37:24 -0000 1.385
+++ vfs_syscalls.c 14 Feb 2009 06:38:43 -0000
@@ -888,7 +888,9 @@
* rest we cannot see, so we don't allow viewing the
* data.
*/
- if (strncmp(bp, sp->f_mntonname, len) == 0 &&
+ if (len == 1)
+ /* our root is / */;
+ else if (strncmp(bp, sp->f_mntonname, len) == 0 &&
((c = sp->f_mntonname[len]) == '/' || c == '\0')) {
(void)strlcpy(sp->f_mntonname, &sp->f_mntonname[len],
sizeof(sp->f_mntonname));
Home |
Main Index |
Thread Index |
Old Index