-
-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95984 from gebner/wofi_do_not_follow_symlink
wofi: do not follow symlinks in PATH
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
diff -r 3414ab984249 modes/run.c | ||
--- a/modes/run.c Tue Aug 11 19:07:49 2020 -0700 | ||
+++ b/modes/run.c Sat Aug 22 13:39:52 2020 +0200 | ||
@@ -91,23 +91,10 @@ | ||
|
||
char* path = strdup(getenv("PATH")); | ||
|
||
- struct map* paths = map_init(); | ||
- | ||
char* save_ptr; | ||
char* str = strtok_r(path, ":", &save_ptr); | ||
do { | ||
|
||
- str = realpath(str, NULL); | ||
- if(str == NULL) { | ||
- continue; | ||
- } | ||
- if(map_contains(paths, str)) { | ||
- free(str); | ||
- continue; | ||
- } | ||
- | ||
- map_put(paths, str, "true"); | ||
- | ||
DIR* dir = opendir(str); | ||
if(dir == NULL) { | ||
continue; | ||
@@ -132,11 +119,9 @@ | ||
} | ||
free(full_path); | ||
} | ||
- free(str); | ||
closedir(dir); | ||
} while((str = strtok_r(NULL, ":", &save_ptr)) != NULL); | ||
free(path); | ||
- map_free(paths); | ||
map_free(cached); | ||
map_free(entries); | ||
} |