aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-15 05:21:47 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-15 05:21:47 +0000
commit51f1b6c0e0160a3c836bc6700c3fa2a43601dfac (patch)
tree04ccdb962b5141ae35ba38f0f96b086d6fa2d6d4
parent4b8171cd7ac73f9dfaf3873ee5a964e6801be9e4 (diff)
downloadbusybox-w32-51f1b6c0e0160a3c836bc6700c3fa2a43601dfac.tar.gz
busybox-w32-51f1b6c0e0160a3c836bc6700c3fa2a43601dfac.tar.bz2
busybox-w32-51f1b6c0e0160a3c836bc6700c3fa2a43601dfac.zip
ls: fix a bug where we may use uninintialized variable
-rw-r--r--coreutils/ls.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index a76ced1b9..f4e71bc6a 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -837,7 +837,8 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
837 int dnfiles; 837 int dnfiles;
838 int dndirs; 838 int dndirs;
839 int i; 839 int i;
840 USE_FEATURE_LS_COLOR(char *color_opt;) 840 /* need to initialize since --color has _an optional_ argument */
841 USE_FEATURE_LS_COLOR(const char *color_opt = "always";)
841 842
842 INIT_G(); 843 INIT_G();
843 844
@@ -888,15 +889,15 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
888 if (ENABLE_FEATURE_LS_COLOR_IS_DEFAULT && isatty(STDOUT_FILENO)) { 889 if (ENABLE_FEATURE_LS_COLOR_IS_DEFAULT && isatty(STDOUT_FILENO)) {
889 char *p = getenv("LS_COLORS"); 890 char *p = getenv("LS_COLORS");
890 /* LS_COLORS is unset, or (not empty && not "none") ? */ 891 /* LS_COLORS is unset, or (not empty && not "none") ? */
891 if (!p || (p[0] && strcmp(p, "none"))) 892 if (!p || (p[0] && strcmp(p, "none") != 0))
892 show_color = 1; 893 show_color = 1;
893 } 894 }
894 if (opt & (1 << i)) { /* next flag after short options */ 895 if (opt & (1 << i)) { /* next flag after short options */
895 if (!color_opt || !strcmp("always", color_opt)) 896 if (strcmp("always", color_opt) == 0)
896 show_color = 1; 897 show_color = 1;
897 else if (color_opt && !strcmp("never", color_opt)) 898 else if (strcmp("never", color_opt) == 0)
898 show_color = 0; 899 show_color = 0;
899 else if (color_opt && !strcmp("auto", color_opt) && isatty(STDOUT_FILENO)) 900 else if (strcmp("auto", color_opt) == 0 && isatty(STDOUT_FILENO))
900 show_color = 1; 901 show_color = 1;
901 } 902 }
902#endif 903#endif