Skip to contentSkip to conversation

exportfs: fix path comparison in unexportfs_parsed()

PATCH In review Scott Mayhew 2 participants 2 messages Dec 15, 2016 – Dec 17, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exportfs: fix path comparison in unexportfs_parsed()

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.

---
 utils/exportfs/exportfs.c | 2 ++
 1 file changed, 2 insertions(+)
utils/exportfs/exportfs.c +2 -0
index b7a910e..a763272 100644
@@ -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)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 5 lines · Scott Mayhew

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.

Committed...

steved.

Quoted 19 lines
---
 utils/exportfs/exportfs.c | 2 ++
 1 file changed, 2 insertions(+)
utils/exportfs/exportfs.c +2 -1
index b7a910e..a763272 100644
@@ -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