Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 May 2019 15:25:27 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r347341 - stable/11/usr.sbin/mountd
Message-ID:  <201905081525.x48FPR1n002790@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed May  8 15:25:27 2019
New Revision: 347341
URL: https://svnweb.freebsd.org/changeset/base/347341

Log:
  MFC r346976: Respect quotes and escapes when splitting exports fields.
  
  Without this r293305 was still unable to handle names with spaces.

Modified:
  stable/11/usr.sbin/mountd/mountd.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/mountd/mountd.c
==============================================================================
--- stable/11/usr.sbin/mountd/mountd.c	Wed May  8 15:25:07 2019	(r347340)
+++ stable/11/usr.sbin/mountd/mountd.c	Wed May  8 15:25:27 2019	(r347341)
@@ -2822,18 +2822,27 @@ static void
 nextfield(char **cp, char **endcp)
 {
 	char *p;
+	char quot = 0;
 
 	p = *cp;
 	while (*p == ' ' || *p == '\t')
 		p++;
-	if (*p == '\n' || *p == '\0')
-		*cp = *endcp = p;
-	else {
-		*cp = p++;
-		while (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\0')
-			p++;
-		*endcp = p;
-	}
+	*cp = p;
+	while (*p != '\0') {
+		if (quot) {
+			if (*p == quot)
+				quot = 0;
+		} else {
+			if (*p == '\\' && *(p + 1) != '\0')
+				p++;
+			else if (*p == '\'' || *p == '"')
+				quot = *p;
+			else if (*p == ' ' || *p == '\t')
+				break;
+		}
+		p++;
+	};
+	*endcp = p;
 }
 
 /*
@@ -2905,8 +2914,8 @@ parsecred(char *namelist, struct xucred *cr)
 	/*
 	 * Get the user's password table entry.
 	 */
-	names = strsep_quote(&namelist, " \t\n");
-	name = strsep(&names, ":");
+	names = namelist;
+	name = strsep_quote(&names, ":");
 	/* Bug?  name could be NULL here */
 	if (isdigit(*name) || *name == '-')
 		pw = getpwuid(atoi(name));
@@ -2950,7 +2959,7 @@ parsecred(char *namelist, struct xucred *cr)
 	}
 	cr->cr_ngroups = 0;
 	while (names != NULL && *names != '\0' && cr->cr_ngroups < XU_NGROUPS) {
-		name = strsep(&names, ":");
+		name = strsep_quote(&names, ":");
 		if (isdigit(*name) || *name == '-') {
 			cr->cr_groups[cr->cr_ngroups++] = atoi(name);
 		} else {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905081525.x48FPR1n002790>