source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Fix incorrect file type tests.
Date: Sun, 26 Jan 2020 06:17:17 -0500 (EST)	[thread overview]
Message-ID: <ba40c5a578bfa1f3@mandoc.bsd.lv> (raw)

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

                 reply	other threads:[~2020-01-26 11:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba40c5a578bfa1f3@mandoc.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).