* mandoc: during prioritization for man(1), correctly extract the section
@ 2021-09-04 22:39 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2021-09-04 22:39 UTC (permalink / raw)
To: source
Log Message:
-----------
during prioritization for man(1), correctly extract the section name
from the file name extension of gzipped manual page files; bug found
on Alpine Linux by Soeren Tempel <soeren at soeren hyphen tempel dot net>,
who also tested this patch
Modified Files:
--------------
mandoc:
main.c
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/main.c,v
retrieving revision 1.357
retrieving revision 1.358
diff -Lmain.c -Lmain.c -u -p -r1.357 -r1.358
--- main.c
+++ main.c
@@ -132,7 +132,7 @@ main(int argc, char *argv[])
struct mparse *mp; /* Opaque parser object. */
const char *conf_file; /* -C: alternate config file. */
const char *os_s; /* -I: Operating system for display. */
- const char *progname, *sec;
+ const char *progname, *sec, *ep;
char *defpaths; /* -M: override manpaths. */
char *auxpaths; /* -m: additional manpaths. */
char *oarg; /* -O: output option string. */
@@ -536,11 +536,16 @@ main(int argc, char *argv[])
sec++; /* Prefer without suffix. */
if (*sec != '/')
prio += 10; /* Wrong dir name. */
- if (search.sec != NULL &&
- (strlen(sec) <= ssz + 3 ||
- strcmp(sec + strlen(sec) - ssz,
- search.sec) != 0))
- prio += 20; /* Wrong file ext. */
+ if (search.sec != NULL) {
+ ep = strchr(sec, '\0');
+ if (ep - sec > 3 &&
+ strncmp(ep - 3, ".gz", 3) == 0)
+ ep -= 3;
+ if ((size_t)(ep - sec) < ssz + 3 ||
+ strncmp(ep - ssz, search.sec,
+ ssz) != 0) /* Wrong file */
+ prio += 20; /* extension. */
+ }
if (prio >= best_prio)
continue;
best_prio = prio;
--
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:[~2021-09-04 22:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-04 22:39 mandoc: during prioritization for man(1), correctly extract the section 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).