From owner-svn-src-stable@FreeBSD.ORG Sun Aug 31 21:56:42 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D1B221CB; Sun, 31 Aug 2014 21:56:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A286F1E7B; Sun, 31 Aug 2014 21:56:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7VLugmm092581; Sun, 31 Aug 2014 21:56:42 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7VLugr1092580; Sun, 31 Aug 2014 21:56:42 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201408312156.s7VLugr1092580@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 31 Aug 2014 21:56:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r270903 - stable/10/usr.sbin/autofs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Aug 2014 21:56:42 -0000 Author: trasz Date: Sun Aug 31 21:56:42 2014 New Revision: 270903 URL: http://svnweb.freebsd.org/changeset/base/270903 Log: MFC r270454: Fix handling of keys in executable maps. Previously it was broken for keys containing whitespace. PR: 192947 Sponsored by: The FreeBSD Foundation Modified: stable/10/usr.sbin/autofs/common.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/autofs/common.c ============================================================================== --- stable/10/usr.sbin/autofs/common.c Sun Aug 31 21:55:08 2014 (r270902) +++ stable/10/usr.sbin/autofs/common.c Sun Aug 31 21:56:42 2014 (r270903) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#define _WITH_GETLINE #include #include #include @@ -213,6 +214,7 @@ node_new(struct node *parent, char *key, TAILQ_INIT(&n->n_children); assert(key != NULL); + assert(key[0] != '\0'); n->n_key = key; if (options != NULL) n->n_options = options; @@ -243,6 +245,7 @@ node_new_map(struct node *parent, char * TAILQ_INIT(&n->n_children); assert(key != NULL); + assert(key[0] != '\0'); n->n_key = key; if (options != NULL) n->n_options = options; @@ -565,6 +568,7 @@ node_path_x(const struct node *n, char * return (x); } + assert(n->n_key[0] != '\0'); path = separated_concat(n->n_key, x, '/'); free(x); @@ -857,33 +861,44 @@ again: } /* - * Parse output of a special map called without argument. This is just - * a list of keys. + * Parse output of a special map called without argument. It is a list + * of keys, separated by newlines. They can contain whitespace, so use + * getline(3) instead of lexer used for maps. */ static void parse_map_keys_yyin(struct node *parent, const char *map) { - char *key = NULL; - int ret; + char *line = NULL, *key; + size_t linecap = 0; + ssize_t linelen; lineno = 1; for (;;) { - ret = yylex(); - - if (ret == NEWLINE) - continue; - - if (ret == 0) { + linelen = getline(&line, &linecap, yyin); + if (linelen < 0) { /* * End of file. */ break; } + if (linelen <= 1) { + /* + * Empty line, consisting of just the newline. + */ + continue; + } + + /* + * "-1" to strip the trailing newline. + */ + key = strndup(line, linelen - 1); - key = checked_strdup(yytext); + log_debugx("adding key \"%s\"", key); node_new(parent, key, NULL, NULL, map, lineno); + lineno++; } + free(line); } static bool