aboutsummaryrefslogtreecommitdiff
path: root/debianutils
diff options
context:
space:
mode:
Diffstat (limited to 'debianutils')
-rw-r--r--debianutils/which.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/debianutils/which.c b/debianutils/which.c
index 1f547919f..a7d55a215 100644
--- a/debianutils/which.c
+++ b/debianutils/which.c
@@ -31,15 +31,12 @@
31int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 31int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
32int which_main(int argc UNUSED_PARAM, char **argv) 32int which_main(int argc UNUSED_PARAM, char **argv)
33{ 33{
34 char *env_path; 34 const char *env_path;
35 int status = 0; 35 int status = 0;
36 /* This sizeof(): bb_default_root_path is shorter than BB_PATH_ROOT_PATH */
37 char buf[sizeof(BB_PATH_ROOT_PATH)];
38 36
39 env_path = getenv("PATH"); 37 env_path = getenv("PATH");
40 if (!env_path) 38 if (!env_path)
41 /* env_path must be writable, and must not alloc, so... */ 39 env_path = bb_default_root_path;
42 env_path = strcpy(buf, bb_default_root_path);
43 40
44 getopt32(argv, "^" "a" "\0" "-1"/*at least one arg*/); 41 getopt32(argv, "^" "a" "\0" "-1"/*at least one arg*/);
45 argv += optind; 42 argv += optind;
@@ -54,7 +51,7 @@ int which_main(int argc UNUSED_PARAM, char **argv)
54 puts(*argv); 51 puts(*argv);
55 } 52 }
56 } else { 53 } else {
57 char *path; 54 const char *path;
58 char *p; 55 char *p;
59 56
60 path = env_path; 57 path = env_path;