diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2022-02-16 13:26:53 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2022-02-16 13:26:53 -0500 |
commit | 516f1c801ade6f9a2b8b60099f9e7e9ffc073db8 (patch) | |
tree | 4a73897eff133dcc90579769e28ba02236427c4c /src | |
parent | 2b4d2bf48d3d1771e25fec6c706434ca01f2d8cf (diff) | |
download | cleanpath-516f1c801ade6f9a2b8b60099f9e7e9ffc073db8.tar.gz |
Avoid clobbering environ (defined by libc)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -15,7 +15,7 @@ static char *program; // Global runtime environment -static char **environ; +static char **runtime; int is_valid_arg(char **args, char *s) { int match; @@ -130,7 +130,7 @@ static void show_usage() { } int main(int argc, char *argv[], char *arge[]) { - environ = arge; + runtime = arge; struct CleanPath *path; char *sep; char *sys_var; @@ -247,19 +247,19 @@ int main(int argc, char *argv[], char *arge[]) { // Initialize path data if (do_all_sys_vars) { - for (size_t i = 0; environ[i] != NULL; i++) { - char *var = getenv_ex(environ[i]); + for (size_t i = 0; runtime[i] != NULL; i++) { + char *var = getenv_ex(runtime[i]); if (!var) { continue; } path = cleanpath_init(var, sep); if (path == NULL) { - fprintf(stderr, "Unexpected error. Invalid data consumed by cleanpath_init(\"%s\", \"%s\")\n", environ[i], sep); + fprintf(stderr, "Unexpected error. Invalid data consumed by cleanpath_init(\"%s\", \"%s\")\n", runtime[i], sep); exit(1); } - char *key = strdup(environ[i]); + char *key = strdup(runtime[i]); char *key_end = strchr(key, '='); if (key_end) { *key_end = '\0'; |