aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/mountd/mountd.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2019-04-30 21:38:38 +0000
committerAlexander Motin <mav@FreeBSD.org>2019-04-30 21:38:38 +0000
commiteb1f7f43ca519028a694da9dce5ec29c443f6481 (patch)
tree38caf10252b0dacf1d9b83bc5bd65439419ffeb0 /usr.sbin/mountd/mountd.c
parentba761eace4ed37065d116f3b7fdf2b87cf3184e3 (diff)
downloadsrc-eb1f7f43ca519028a694da9dce5ec29c443f6481.tar.gz
src-eb1f7f43ca519028a694da9dce5ec29c443f6481.zip
Respect quotes and escapes when splitting exports fields.
Without this r293305 was still unable to handle names with spaces. MFC after: 1 week Sponsored by: iXsystems, Inc.
Notes
Notes: svn path=/head/; revision=346976
Diffstat (limited to 'usr.sbin/mountd/mountd.c')
-rw-r--r--usr.sbin/mountd/mountd.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 03a084dec033..1bab9881c90f 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -2824,18 +2824,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;
}
/*
@@ -2907,8 +2916,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));
@@ -2952,7 +2961,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 {