aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/autofs/common.c
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2014-09-23 19:12:06 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2014-09-23 19:12:06 +0000
commitc37463b3e8eeb185c4329493307151cc252029a6 (patch)
tree3d159eb3ae5b562a5873a86ef80fa2e2a7c654bf /usr.sbin/autofs/common.c
parent54432196dbbd70b3e66a6b1f4010a3e5332ca7d7 (diff)
downloadsrc-c37463b3e8eeb185c4329493307151cc252029a6.tar.gz
src-c37463b3e8eeb185c4329493307151cc252029a6.zip
Fix thinko that, with two map entries like shown below, in that order,
made automountd(8) mix them up: trying to access the second one would trigger mount for the first one. foo host:/foo foobar host:/foobar PR: 193584 MFC after: 3 days Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=272037
Diffstat (limited to 'usr.sbin/autofs/common.c')
-rw-r--r--usr.sbin/autofs/common.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c
index 1d1117c2ba8e..cefbcc8b3104 100644
--- a/usr.sbin/autofs/common.c
+++ b/usr.sbin/autofs/common.c
@@ -673,11 +673,21 @@ node_find(struct node *node, const char *path)
{
struct node *child, *found;
char *tmp;
+ size_t tmplen;
//log_debugx("looking up %s in %s", path, node->n_key);
tmp = node_path(node);
- if (strncmp(tmp, path, strlen(tmp)) != 0) {
+ tmplen = strlen(tmp);
+ if (strncmp(tmp, path, tmplen) != 0) {
+ free(tmp);
+ return (NULL);
+ }
+ if (path[tmplen] != '/' && path[tmplen] != '\0') {
+ /*
+ * If we have two map entries like 'foo' and 'foobar', make
+ * sure the search for 'foobar' won't match 'foo' instead.
+ */
free(tmp);
return (NULL);
}