Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Feb 2018 21:00:06 +0000 (UTC)
From:      Bryan Drewery <bdrewery@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: r328807 - stable/11/usr.sbin/makefs
Message-ID:  <201802022100.w12L06as099778@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Fri Feb  2 21:00:06 2018
New Revision: 328807
URL: https://svnweb.freebsd.org/changeset/base/328807

Log:
  MFC r322894:
  
    Replace makefs' hand-rolled unescaping with strunvis
  
  Sponsored by:	Dell EMC

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

Modified: stable/11/usr.sbin/makefs/mtree.c
==============================================================================
--- stable/11/usr.sbin/makefs/mtree.c	Fri Feb  2 19:42:02 2018	(r328806)
+++ stable/11/usr.sbin/makefs/mtree.c	Fri Feb  2 21:00:06 2018	(r328807)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 #include <strings.h>
 #include <unistd.h>
+#include <vis.h>
 
 #include "makefs.h"
 
@@ -359,8 +360,6 @@ read_word(FILE *fp, char *buf, size_t bufsz)
 			break;
 		case '\\':
 			esc++;
-			if (esc == 1)
-				continue;
 			break;
 		case '`':
 		case '\'':
@@ -405,34 +404,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;
@@ -607,7 +582,15 @@ read_mtree_keywords(FILE *fp, fsnode *node)
 					error = ENOATTR;
 					break;
 				}
-				node->symlink = strdup(value);
+				node->symlink = malloc(strlen(value) + 1);
+				if (node->symlink == NULL) {
+					error = errno;
+					break;
+				}
+				if (strunvis(node->symlink, value) < 0) {
+					error = errno;
+					break;
+				}
 			} else
 				error = ENOSYS;
 			break;
@@ -987,13 +970,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) {



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