Module Name:    src
Committed By:   snj
Date:           Tue Jan  5 22:18:27 UTC 2016

Modified Files:
        src/usr.bin/man [netbsd-7]: man.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1057):
        usr.bin/man/man.c: revision 1.62
For an argument to be interpreted as a local file name, bypassing the
search rules in man.conf or MANPATH, it must begin with "/", "./", or
"../".  Simply testing whether it contains "/" is wrong, because it
breaks usage like "man 8 vax/boot".
This reverts revision 1.57 dated 2013-10-06,
"Be more permissive in interpreting man pages as filenames".


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.61.4.1 src/usr.bin/man/man.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/man/man.c
diff -u src/usr.bin/man/man.c:1.61 src/usr.bin/man/man.c:1.61.4.1
--- src/usr.bin/man/man.c:1.61	Mon Feb 17 03:10:12 2014
+++ src/usr.bin/man/man.c	Tue Jan  5 22:18:27 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: man.c,v 1.61 2014/02/17 03:10:12 uwe Exp $	*/
+/*	$NetBSD: man.c,v 1.61.4.1 2016/01/05 22:18:27 snj Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994, 1995
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19
 #if 0
 static char sccsid[] = "@(#)man.c	8.17 (Berkeley) 1/31/95";
 #else
-__RCSID("$NetBSD: man.c,v 1.61 2014/02/17 03:10:12 uwe Exp $");
+__RCSID("$NetBSD: man.c,v 1.61.4.1 2016/01/05 22:18:27 snj Exp $");
 #endif
 #endif /* not lint */
 
@@ -574,10 +574,14 @@ manual(char *page, struct manstate *mp, 
 	*eptr = '\0';
 
 	/*
-	 * If 'page' contains a slash then it's
-	 * interpreted as a file specification.
+	 * If 'page' is given with an absolute path,
+	 * or a relative path explicitly beginning with "./"
+	 * or "../", then interpret it as a file specification.
 	 */
-	if (strchr(page, '/') != NULL) {
+	if ((page[0] == '/')
+	    || (page[0] == '.' && page[1] == '/')
+	    || (page[0] == '.' && page[1] == '.' && page[2] == '/')
+	    ) {
 		/* check if file actually exists */
 		(void)strlcpy(buf, escpage, sizeof(buf));
 		error = glob(buf, GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg);

Reply via email to