summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/cmd/ls/ls.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr/src/cmd/ls/ls.c b/usr/src/cmd/ls/ls.c
index 6b3bbd7d72..3777cfbdfa 100644
--- a/usr/src/cmd/ls/ls.c
+++ b/usr/src/cmd/ls/ls.c
@@ -3058,7 +3058,11 @@ ls_color_init()
if ((colorstr = getenv("LS_COLORS")) == NULL)
colorstr = default_colorstr;
- color_sz = 0;
+ /*
+ * Determine the size of lsc_colors. color_sz can be > lsc_ncolors
+ * if there are invalid entries passed in the string (they are ignored)
+ */
+ color_sz = 1;
for (p = strchr(colorstr, ':'); p != NULL && *p != '\0';
p = strchr(++p, ':'))
++color_sz;