source@mandoc.bsd.lv
 help / color / Atom feed
* mandoc: Fix incorrect file type tests.
@ 2020-01-26 11:17 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2020-01-26 11:17 UTC (permalink / raw)
  To: source

Log Message:
-----------
Fix incorrect file type tests.
This bug caused sockets and character special devices to be accepted
as manual pages if they appeared inside manpaths, and 
it caused incorrect file names to be entered into the database when
the manpath or one of its parent directories was a symbolic link.
This fixes the issues reported by <Andreas dot Kahari at abc dot se> 
on ports@, but additional issues remain when symbolic links are
contained in a manpath that involves another symbolic link.

Modified Files:
--------------
    mandoc:
        mandocdb.c

Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandocdb.c,v
retrieving revision 1.264
retrieving revision 1.265
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.264 -r1.265
--- mandocdb.c
+++ mandocdb.c
@@ -801,7 +801,7 @@ filescan(const char *file)
 		exitcode = (int)MANDOCLEVEL_BADARG;
 		say(file, "&lstat");
 		return;
-	} else if ((st.st_mode & (S_IFREG | S_IFLNK)) == 0) {
+	} else if (S_ISREG(st.st_mode) == 0 && S_ISLNK(st.st_mode) == 0) {
 		exitcode = (int)MANDOCLEVEL_BADARG;
 		say(file, "Not a regular file");
 		return;
@@ -840,7 +840,7 @@ filescan(const char *file)
 	 * Note the stat(2) can still fail if the link target
 	 * doesn't exist.
 	 */
-	if (st.st_mode & S_IFLNK) {
+	if (S_ISLNK(st.st_mode)) {
 		if (stat(buf, &st) == -1) {
 			exitcode = (int)MANDOCLEVEL_BADARG;
 			say(file, "&stat");
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-26 11:17 mandoc: Fix incorrect file type tests schwarze

source@mandoc.bsd.lv

Archives are clonable: git clone --mirror http://inbox.vuxu.org/mandoc-source

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git