summaryrefslogtreecommitdiff
path: root/src/zsoelim.l
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2019-01-26 12:55:56 +0000
committerColin Watson <cjwatson@debian.org>2019-01-26 12:55:56 +0000
commit199a6e80e7b4baa27e195f2c1120c45df9ea4e67 (patch)
treed3a6b7b51caa32a576ca2061590c11d7514c178e /src/zsoelim.l
parent4f07b2663de8cb7e85c779b9d2c3142134847b35 (diff)
Remove arbitrary limit on manpath size
Fixes Savannah bug #50324. * bootstrap.conf (gnulib_modules): Add hash-pjw-bare, linkedhash-list, stdbool, and xlist. * include/manconfig.h.in (MAXDIRS): Remove. * src/manp.c (tmplist): Remove. (string_equals, string_hash, string_free): New functions. (gripe_overlong_list): Remove. (insert_override_dir, get_manpath_from_path, add_expanded_dir_to_list, add_dir_to_list, add_man_subdirs, add_dir_to_path_list, create_pathlist, free_pathlist): Port manpath list handling to gl_list_t. * src/catman.c (main): Likewise. * src/man.c (do_global_apropos, local_man_loop, locate_page_in_manpath, main): Likewise. * src/mandb.c (main): Likewise. * src/whatis.c (suitable_manpath, search, main): Likewise. * src/zsoelim.l (<<EOF>>, zsoelim_parse_file, zsoelim_open_file, zsoelim_stdin, zsoelim_stdin_data_new): Likewise. * src/zsoelim_main.c (main): Likewise. * src/manp.h (create_pathlist, free_pathlist): Update prototypes. * src/zsoelim.h (zsoelim_open_file, zsoelim_parse_file, zsoelim_stdin_data_new): Likewise. * NEWS: Document this.
Diffstat (limited to 'src/zsoelim.l')
-rw-r--r--src/zsoelim.l46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/zsoelim.l b/src/zsoelim.l
index b3dc7807..c6ce8b4c 100644
--- a/src/zsoelim.l
+++ b/src/zsoelim.l
@@ -59,6 +59,8 @@
#define PIPE so_pipe[so_stack_ptr]
#include "dirname.h"
+#include "gl_linkedhash_list.h"
+#include "gl_xlist.h"
#include "xgetcwd.h"
#include "xvasprintf.h"
@@ -88,12 +90,12 @@ static int so_line[MAX_SO_DEPTH];
static pipeline *so_pipe[MAX_SO_DEPTH];
static int so_stack_ptr;
static int no_newline;
-static char * const *so_manpathlist;
+static gl_list_t so_manpathlist;
static const char *so_parent_path;
struct zsoelim_stdin_data {
char *path;
- char * const *manpathlist;
+ gl_list_t manpathlist;
};
/* The flex documentation says that yyin is only used by YY_INPUT, so we
@@ -286,7 +288,6 @@ W [ \t]
PIPE = NULL;
free (NAME);
NAME = NULL;
- so_manpathlist = NULL;
if (no_newline)
putchar ('\n');
@@ -320,7 +321,7 @@ static void zap_quotes (void)
#endif
/* initialise the stack and call the parser */
-void zsoelim_parse_file (char * const *manpathlist, const char *parent_path)
+void zsoelim_parse_file (gl_list_t manpathlist, const char *parent_path)
{
#ifdef PP_COOKIE
const char *line;
@@ -377,11 +378,10 @@ static pipeline *try_compressed (char **filename)
/* This routine is used to open the specified file or uncompress a compressed
version and open that instead */
-int zsoelim_open_file (const char *filename, char * const *manpathlist,
+int zsoelim_open_file (const char *filename, gl_list_t manpathlist,
const char *parent_path)
{
pipeline *decomp;
- char * const *mp;
if (parent_path)
debug ("opening %s (parent path: %s)\n",
@@ -394,6 +394,8 @@ int zsoelim_open_file (const char *filename, char * const *manpathlist,
NAME = xstrdup (filename);
} else {
char *compfile;
+ gl_list_iterator_t mpiter;
+ const char *mp;
/* If there is no parent path, try opening directly first. */
if (!parent_path) {
@@ -407,7 +409,7 @@ int zsoelim_open_file (const char *filename, char * const *manpathlist,
free (compfile);
}
- if (manpathlist && strchr (filename, '/')) {
+ if (strchr (filename, '/')) {
/* File name with a directory part. Try looking it
* up within each manpath entry.
*/
@@ -424,11 +426,14 @@ int zsoelim_open_file (const char *filename, char * const *manpathlist,
free (compfile);
}
- for (mp = manpathlist; *mp; ++mp) {
- if (parent_path && STREQ (*mp, parent_path))
+ mpiter = gl_list_iterator (manpathlist);
+ while (gl_list_iterator_next (&mpiter,
+ (const void **) &mp,
+ NULL)) {
+ if (parent_path && STREQ (mp, parent_path))
continue;
- compfile = xasprintf ("%s/%s.", *mp, filename);
+ compfile = xasprintf ("%s/%s.", mp, filename);
decomp = try_compressed (&compfile);
if (decomp) {
@@ -438,7 +443,8 @@ int zsoelim_open_file (const char *filename, char * const *manpathlist,
free (compfile);
}
- } else if (manpathlist) {
+ gl_list_iterator_free (&mpiter);
+ } else {
/* File name with no directory part. Try searching
* the manpath.
*/
@@ -470,11 +476,14 @@ int zsoelim_open_file (const char *filename, char * const *manpathlist,
}
}
- for (mp = manpathlist; *mp; ++mp) {
- if (parent_path && STREQ (*mp, parent_path))
+ mpiter = gl_list_iterator (manpathlist);
+ while (gl_list_iterator_next (&mpiter,
+ (const void **) &mp,
+ NULL)) {
+ if (parent_path && STREQ (mp, parent_path))
continue;
- names = look_for_file (*mp, sec, name,
+ names = look_for_file (mp, sec, name,
0, LFF_MATCHCASE);
for (np = names; np && *np; ++np) {
decomp = decompress_open (*np);
@@ -484,6 +493,7 @@ int zsoelim_open_file (const char *filename, char * const *manpathlist,
}
}
}
+ gl_list_iterator_free (&mpiter);
free (name);
}
@@ -520,13 +530,17 @@ out:
void zsoelim_stdin (void *data)
{
struct zsoelim_stdin_data *zsoelim_data = data;
+ gl_list_t empty;
- zsoelim_open_file ("-", NULL, zsoelim_data->path);
+ empty = gl_list_create_empty (GL_LINKEDHASH_LIST, NULL, NULL, NULL,
+ true);
+ zsoelim_open_file ("-", empty, zsoelim_data->path);
+ gl_list_free (empty);
zsoelim_parse_file (zsoelim_data->manpathlist, zsoelim_data->path);
}
struct zsoelim_stdin_data *zsoelim_stdin_data_new (const char *path,
- char * const *manpathlist)
+ gl_list_t manpathlist)
{
struct zsoelim_stdin_data *data = XMALLOC (struct zsoelim_stdin_data);