summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2020-01-26 11:15:49 +0000
committerschwarze <schwarze@openbsd.org>2020-01-26 11:15:49 +0000
commit7fec9d6ae7ec8b729d43b8a01a15c5e8e82cab6f (patch)
treea19bc040c2da863de85c23f4b7fe5448cd719d09
parent- sprinkle some Fn for function names and Pa for paths (diff)
downloadwireguard-openbsd-7fec9d6ae7ec8b729d43b8a01a15c5e8e82cab6f.tar.xz
wireguard-openbsd-7fec9d6ae7ec8b729d43b8a01a15c5e8e82cab6f.zip
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.
-rw-r--r--usr.bin/mandoc/mandocdb.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index 7fe749c45ba..a06b488ecb0 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandocdb.c,v 1.213 2020/01/25 22:59:14 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.214 2020/01/26 11:15:49 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2020 Ingo Schwarze <schwarze@openbsd.org>
@@ -767,7 +767,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;
@@ -802,7 +802,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");