summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-12-17 18:45:00 +0000
committerschwarze <schwarze@openbsd.org>2014-12-17 18:45:00 +0000
commitafe74b66c9d3a5ef85096f8c4c9fb32f607baf6c (patch)
treecd6c0fdecb3c0416139aa77461500f5b87858d68
parentAdd size_t to int checks for SSL functions. (diff)
downloadwireguard-openbsd-afe74b66c9d3a5ef85096f8c4c9fb32f607baf6c.tar.xz
wireguard-openbsd-afe74b66c9d3a5ef85096f8c4c9fb32f607baf6c.zip
Be a bit more lenient in what to accept for section names given
as the first man(1) command line argument without -s: Accept digits like "1", "2"; digit+letter like "3p", "1X"; and "n". Issue reported by Svyatoslav Mishyn <juef at openmailbox dot org> (Crux Linux).
-rw-r--r--usr.bin/mandoc/main.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index 28b305f1f57..086fe7acdf7 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.112 2014/12/15 18:04:32 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.113 2014/12/17 18:45:00 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -103,6 +103,7 @@ main(int argc, char *argv[])
struct manpaths paths;
char *auxpaths;
char *defos;
+ unsigned char *uc;
struct manpage *res, *resp;
char *conf_file, *defpaths;
size_t isec, i, sz;
@@ -283,11 +284,11 @@ main(int argc, char *argv[])
argv = help_argv;
argc = 1;
}
- } else if (argv[0] != NULL && (
- (isdigit((unsigned char)argv[0][0]) &&
- (argv[0][1] == '\0' || !strcmp(argv[0], "3p"))) ||
- (argv[0][0] == 'n' && argv[0][1] == '\0'))) {
- search.sec = argv[0];
+ } else if (((uc = argv[0]) != NULL) &&
+ ((isdigit(uc[0]) && (uc[1] == '\0' ||
+ (isalpha(uc[1]) && uc[2] == '\0'))) ||
+ (uc[0] == 'n' && uc[1] == '\0'))) {
+ search.sec = uc;
argv++;
argc--;
}