diff options
author | Colin Watson <cjwatson@debian.org> | 2022-01-30 01:24:31 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2022-01-30 01:24:31 +0000 |
commit | 8966aafcfaba56aa811cb6b5d312d5b33db27d71 (patch) | |
tree | 6cd20016b72ec795071daa17d8c5f5d3172999c5 /src/man.c | |
parent | 1e5389b0cee98e41124260ec7d582ab0b12554f5 (diff) |
man: Don't modify MANSECT environment variable
Reported and diagnosed by Rob Hoelz. Fixes Savannah bug #58896.
* src/man.c (get_section_list): Copy colon_sep_section_list before
passing it to strtok.
* NEWS.md: Document this.
Diffstat (limited to 'src/man.c')
-rw-r--r-- | src/man.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -3970,6 +3970,7 @@ static int man (const char *name, int *found) static gl_list_t get_section_list (void) { gl_list_t config_sections, sections; + char *section_list_copy; const char *sec; /* Section list from configuration file, or STD_SECTIONS if it's @@ -3993,9 +3994,11 @@ static gl_list_t get_section_list (void) * too for compatibility. */ sections = new_string_list (GL_ARRAY_LIST, true); - for (sec = strtok (colon_sep_section_list, ":,"); sec; + section_list_copy = xstrdup (colon_sep_section_list); + for (sec = strtok (section_list_copy, ":,"); sec; sec = strtok (NULL, ":,")) gl_list_add_last (sections, xstrdup (sec)); + free (section_list_copy); if (gl_list_size (sections)) { gl_list_free (config_sections); |