diff mbox

[-,nfs-utils] mountd: fix next_mnt handling for "/"

Message ID 20150216121856.7efe2237@notabene.brown (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown Feb. 16, 2015, 1:18 a.m. UTC
If the (exported) path passed to next_mnt() is simply "/", next_mnt()
will not report any children, as none start with "/" followed by
a '/'.
So make a special case for strlen(p)==1.  In that case, return all
children.

This gives correct handling if only "/" is exported.

Signed-off-by: NeilBrown <neilb@suse.de>

Comments

Steve Dickson Feb. 26, 2015, 7:37 p.m. UTC | #1
On 02/15/2015 08:18 PM, NeilBrown wrote:
> 
> 
> If the (exported) path passed to next_mnt() is simply "/", next_mnt()
> will not report any children, as none start with "/" followed by
> a '/'.
> So make a special case for strlen(p)==1.  In that case, return all
> children.
> 
> This gives correct handling if only "/" is exported.
> 
> Signed-off-by: NeilBrown <neilb@suse.de>
Committed!

steved.

> 
> diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
> index c23d384d24eb..ac36b6d9f21e 100644
> --- a/utils/mountd/cache.c
> +++ b/utils/mountd/cache.c
> @@ -377,6 +377,7 @@ static char *next_mnt(void **v, char *p)
>  	} else
>  		f = *v;
>  	while ((me = getmntent(f)) != NULL &&
> +	       l > 1 &&
>  	       (strncmp(me->mnt_dir, p, l) != 0 ||
>  		me->mnt_dir[l] != '/'))
>  		;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index c23d384d24eb..ac36b6d9f21e 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -377,6 +377,7 @@  static char *next_mnt(void **v, char *p)
 	} else
 		f = *v;
 	while ((me = getmntent(f)) != NULL &&
+	       l > 1 &&
 	       (strncmp(me->mnt_dir, p, l) != 0 ||
 		me->mnt_dir[l] != '/'))
 		;