From owner-svn-src-all@freebsd.org Fri Aug 25 16:10:17 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BCDBEDDBE57; Fri, 25 Aug 2017 16:10:17 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 9770F66015; Fri, 25 Aug 2017 16:10:17 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PGAGMn051555; Fri, 25 Aug 2017 16:10:16 GMT (envelope-from benno@FreeBSD.org) Received: (from benno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PGAGJ9051554; Fri, 25 Aug 2017 16:10:16 GMT (envelope-from benno@FreeBSD.org) Message-Id: <201708251610.v7PGAGJ9051554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: benno set sender to benno@FreeBSD.org using -f From: Benno Rice Date: Fri, 25 Aug 2017 16:10:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322894 - head/usr.sbin/makefs X-SVN-Group: head X-SVN-Commit-Author: benno X-SVN-Commit-Paths: head/usr.sbin/makefs X-SVN-Commit-Revision: 322894 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 16:10:17 -0000 Author: benno Date: Fri Aug 25 16:10:16 2017 New Revision: 322894 URL: https://svnweb.freebsd.org/changeset/base/322894 Log: Replace makefs' hand-rolled unescaping with strunvis mtree path names and link attributes are encoded, generally using strvis. Newer versions of mtree will use C-style escapes but previously the accepted form was octal escapes. makefs' mtree code spots the C-style escapes but fails to deal with octal escapes correctly. Remove mtree's escape-decoding code (except for a few instances where it's needed) and instead pass pathnames and link targets through strunvis prior to use. Reviewed by: marcel MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D12104 Modified: head/usr.sbin/makefs/mtree.c Modified: head/usr.sbin/makefs/mtree.c ============================================================================== --- head/usr.sbin/makefs/mtree.c Fri Aug 25 15:31:55 2017 (r322893) +++ head/usr.sbin/makefs/mtree.c Fri Aug 25 16:10:16 2017 (r322894) @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "makefs.h" @@ -355,8 +356,6 @@ read_word(FILE *fp, char *buf, size_t bufsz) break; case '\\': esc++; - if (esc == 1) - continue; break; case '`': case '\'': @@ -401,34 +400,10 @@ read_word(FILE *fp, char *buf, size_t bufsz) fi->line++; } break; - case 'a': + default: if (esc) - c = '\a'; + buf[idx++] = '\\'; break; - case 'b': - if (esc) - c = '\b'; - break; - case 'f': - if (esc) - c = '\f'; - break; - case 'n': - if (esc) - c = '\n'; - break; - case 'r': - if (esc) - c = '\r'; - break; - case 't': - if (esc) - c = '\t'; - break; - case 'v': - if (esc) - c = '\v'; - break; } buf[idx++] = c; esc = 0; @@ -591,7 +566,15 @@ read_mtree_keywords(FILE *fp, fsnode *node) error = ENOATTR; break; } - node->symlink = estrdup(value); + node->symlink = emalloc(strlen(value) + 1); + if (node->symlink == NULL) { + error = errno; + break; + } + if (strunvis(node->symlink, value) < 0) { + error = errno; + break; + } } else error = ENOSYS; break; @@ -971,13 +954,18 @@ read_mtree_spec1(FILE *fp, bool def, const char *name) static int read_mtree_spec(FILE *fp) { - char pathspec[PATH_MAX]; + char pathspec[PATH_MAX], pathtmp[4*PATH_MAX + 1]; char *cp; int error; - error = read_word(fp, pathspec, sizeof(pathspec)); + error = read_word(fp, pathtmp, sizeof(pathtmp)); if (error) goto out; + if (strnunvis(pathspec, PATH_MAX, pathtmp) == -1) { + error = errno; + goto out; + } + error = 0; cp = strchr(pathspec, '/'); if (cp != NULL) {