aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vorel <petr.vorel@gmail.com>2017-10-13 15:57:16 +0200
committerStephen Hemminger <stephen@networkplumber.org>2017-10-16 09:24:11 -0700
commite6849a5722dc248a1fe0519c97094000ded3849c (patch)
tree1d65938f9af58a88560827857470562b7e5ea371
parentf1241a7e3b800d8325eb710744289b10f92ef12d (diff)
downloadplatform_external_iproute2-e6849a5722dc248a1fe0519c97094000ded3849c.tar.gz
platform_external_iproute2-e6849a5722dc248a1fe0519c97094000ded3849c.tar.bz2
platform_external_iproute2-e6849a5722dc248a1fe0519c97094000ded3849c.zip
color: Fix ip segfault when using --color switch
Commit d0e72011 ("ip: ipaddress.c: add support for json output") introduced passing -1 as enum color_attr. This is not only wrong as no color_attr has value -1, but also causes another segfault in color_fprintf() on this setup as there is no item with index -1 in array of enum attr_colors[]. Using COLOR_CLEAR is valid option. Reproduce with: $ COLORFGBG='0;15' ip -c a NOTE: COLORFGBG is environmental variable used for defining whether user has light or dark background. COLORFGBG="0;15" is used to ask for color set suitable for light background, COLORFGBG="15;0" is used to ask for color set suitable for dark background. Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
-rw-r--r--include/json_print.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/json_print.h b/include/json_print.h
index b6ce1f9f..596af35a 100644
--- a/include/json_print.h
+++ b/include/json_print.h
@@ -53,7 +53,7 @@ void close_json_array(enum output_type type, const char *delim);
const char *fmt, \
type value) \
{ \
- print_color_##type_name(t, -1, key, fmt, value); \
+ print_color_##type_name(t, COLOR_CLEAR, key, fmt, value); \
}
_PRINT_FUNC(int, int);
_PRINT_FUNC(bool, bool);