summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-04-11 01:43:34 +0000
committerJim Meyering <jim@meyering.net>1999-04-11 01:43:34 +0000
commit23dfcdb3689f1e030a14fb312b683cd6c82a57d2 (patch)
tree2c359a1f8974f865bbc0dfc820906e851aa0d0ee
parente6a9ce41b69671ff5f2ec5d05a5c38ef2d47c673 (diff)
downloadcoreutils-23dfcdb3689f1e030a14fb312b683cd6c82a57d2.tar.xz
`ls --color' would segfault
Include assert.h. (color_indicator[]): Add an entry for the type, `door.' (main): Assert that the lengths of the color_indicator and indicator_name arrays are appropriately related.
-rw-r--r--src/ls.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ls.c b/src/ls.c
index 6a16d5400..6ebdeb52d 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -65,6 +65,7 @@
#endif
#include <stdio.h>
+#include <assert.h>
#include <grp.h>
#include <pwd.h>
#include <getopt.h>
@@ -461,7 +462,8 @@ static struct bin_str color_indicator[] =
{ LEN_STR_PAIR ("01;33") }, /* cd: Char device: bright yellow */
{ 0, NULL }, /* mi: Missing file: undefined */
{ 0, NULL }, /* or: Orphanned symlink: undefined */
- { LEN_STR_PAIR ("01;32") } /* ex: Executable: bright green */
+ { LEN_STR_PAIR ("01;32") }, /* ex: Executable: bright green */
+ { LEN_STR_PAIR ("01;35") } /* do: Door: bright magenta */
};
/* FIXME: comment */
@@ -740,6 +742,9 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+#define N_ENTRIES(Array) (sizeof Array / sizeof *(Array))
+ assert (N_ENTRIES (color_indicator) + 1 == N_ENTRIES (indicator_name));
+
exit_status = 0;
dir_defaulted = 1;
print_dir_name = 1;