diff mbox

[nfs-utils] exportfs: fix path comparison in unexportfs_parsed()

Message ID 1481830641-15595-1-git-send-email-smayhew@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Scott Mayhew Dec. 15, 2016, 7:37 p.m. UTC
Passing a path like /export1 to unexportfs_parsed() matches not only
/export1, but /export11, /export100, /export1forthemoney, etc. which can
result in some nasty surprises when unexporting individual exports.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 utils/exportfs/exportfs.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Steve Dickson Dec. 17, 2016, 6:43 p.m. UTC | #1
On 12/15/2016 02:37 PM, Scott Mayhew wrote:
> Passing a path like /export1 to unexportfs_parsed() matches not only
> /export1, but /export11, /export100, /export1forthemoney, etc. which can
> result in some nasty surprises when unexporting individual exports.
> 
> Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Committed... 

steved.

> ---
>  utils/exportfs/exportfs.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
> index b7a910e..a763272 100644
> --- a/utils/exportfs/exportfs.c
> +++ b/utils/exportfs/exportfs.c
> @@ -345,6 +345,8 @@ unexportfs_parsed(char *hname, char *path, int verbose)
>  		nlen--;
>  
>  	for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) {
> +		if (strlen(exp->m_export.e_path) != nlen)
> +			continue;
>  		if (path && strncmp(path, exp->m_export.e_path, nlen))
>  			continue;
>  		if (htype != exp->m_client->m_type)
> -- 2.7.4
> 
--
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/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index b7a910e..a763272 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -345,6 +345,8 @@  unexportfs_parsed(char *hname, char *path, int verbose)
 		nlen--;
 
 	for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) {
+		if (strlen(exp->m_export.e_path) != nlen)
+			continue;
 		if (path && strncmp(path, exp->m_export.e_path, nlen))
 			continue;
 		if (htype != exp->m_client->m_type)