From 867533b50023abd39552f7026484f3335f165db8 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 26 Jan 2020 11:16:47 +0000 Subject: 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 on ports@, but additional issues remain when symbolic links are contained in a manpath that involves another symbolic link. --- mandocdb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mandocdb.c') diff --git a/mandocdb.c b/mandocdb.c index 6ac2f1a8..6668b075 100644 --- a/mandocdb.c +++ b/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.264 2020/01/25 22:59:22 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.265 2020/01/26 11:16:47 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011-2020 Ingo Schwarze @@ -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"); -- cgit v1.2.3-56-ge451