All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Sanity checks for brackets (escaped or otherwise) in server name
@ 2011-04-01  9:13 Siddhesh Poyarekar
  2011-04-07 14:42 ` Ian Kent
  0 siblings, 1 reply; 2+ messages in thread
From: Siddhesh Poyarekar @ 2011-04-01  9:13 UTC (permalink / raw)
  To: autofs; +Cc: Siddhesh Poyarekar

When autofs is configured as follows:

* -nodev,nosuid,intr,soft,retry=10,proto=tcp &:/tmp1

One could make a mount request as follows:

df /autom/tmp1/som\(efile

and crash automount, since automount tries to parse the brackets to
get the weight for the server. Automount should not parse these
brackets if they're escaped.

Also throw a syntax error in case of mismatched brackets instead of
crashing. Sample configuration for this:

* -nodev,nosuid,intr,soft,retry=10,proto=tcp foo(2:/tmp1

Signed-off-by: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
---
 modules/replicated.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/modules/replicated.c b/modules/replicated.c
index 975c254..248da54 100644
--- a/modules/replicated.c
+++ b/modules/replicated.c
@@ -1206,7 +1206,7 @@ static char *seek_delim(const char *s)
 	char *delim;
 
 	delim = strpbrk(p, "(, \t:");
-	if (delim && *delim != ':')
+	if (delim && *delim != ':' && (delim == s || *(delim - 1) != '\\'))
 		return delim;
 
 	while (*p) {
@@ -1255,6 +1255,12 @@ int parse_location(unsigned logopt, struct host **hosts,
 					*delim = '\0';
 					weight = atoi(w);
 				}
+				else {
+					/* syntax error - Mismatched brackets */
+					free_host_list(hosts);
+					free(str);
+					return 0;
+				}
 				delim++;
 			}
 
-- 
1.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-07 14:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-01  9:13 [PATCH] Sanity checks for brackets (escaped or otherwise) in server name Siddhesh Poyarekar
2011-04-07 14:42 ` Ian Kent

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.