summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2014-11-30 19:39:58 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2014-11-30 19:39:58 +0100
commit476654cdbeb2923fc5d2485701587b42579e1635 (patch)
tree529d6eba749e26fe88d944f50399b499402bab6d
parent8d75d794ea505003fddea8e757d43976db8d6861 (diff)
man: do not mangle $MANPATH in memory
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/man.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/miscutils/man.c b/miscutils/man.c
index ccb57a93f..c39870e67 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -155,9 +155,9 @@ static char **add_MANPATH(char **man_path_list, int *count_mp, char *path)
next_path = strchr(path, ':');
if (next_path) {
- *next_path = '\0';
- if (next_path++ == path) /* "::"? */
+ if (next_path == path) /* "::"? */
goto next;
+ *next_path = '\0';
}
/* Do we already have path? */
path_element = man_path_list;
@@ -174,8 +174,10 @@ static char **add_MANPATH(char **man_path_list, int *count_mp, char *path)
skip:
if (!next_path)
break;
+ /* "path" may be a result of getenv(), be nice and don't mangle it */
+ *next_path = ':';
next:
- path = next_path;
+ path = next_path + 1;
}
return man_path_list;
}