source@mandoc.bsd.lv
 help / color / mirror / 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, other threads:[~2020-01-26 11:17 UTC | newest]

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).