From 1c06f8b797bcd4cb142dbb7169aa5cce1ae1f50e Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 12 Jul 2017 17:50:10 -0400 Subject: [PATCH 1/2] i3bar: change error block color to hex Named colors are not supported by the i3bar protocol so give the error block color in hex. --- i3bar/src/child.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 60ab462a..814f0411 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -112,13 +112,13 @@ __attribute__((format(printf, 1, 2))) static void set_statusline_error(const cha struct status_block *err_block = scalloc(1, sizeof(struct status_block)); err_block->full_text = i3string_from_utf8("Error: "); err_block->name = sstrdup("error"); - err_block->color = sstrdup("red"); + err_block->color = sstrdup("#ff0000"); err_block->no_separator = true; struct status_block *message_block = scalloc(1, sizeof(struct status_block)); message_block->full_text = i3string_from_utf8(message); message_block->name = sstrdup("error_message"); - message_block->color = sstrdup("red"); + message_block->color = sstrdup("#ff0000"); message_block->no_separator = true; TAILQ_INSERT_HEAD(&statusline_head, err_block, blocks); From 3a914396df50441377f1d0f17912653dd4bba4cf Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 12 Jul 2017 17:50:19 -0400 Subject: [PATCH 2/2] libi3: Add basic validation to hex color conversion Make sure a given hex color is the expected length and begins with a hash in draw_util_hex_to_color() to avoid memory errors. fixes #2829 --- libi3/draw_util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libi3/draw_util.c b/libi3/draw_util.c index e4f0d065..6a2e93dc 100644 --- a/libi3/draw_util.c +++ b/libi3/draw_util.c @@ -84,6 +84,11 @@ void draw_util_surface_set_size(surface_t *surface, int width, int height) { * */ color_t draw_util_hex_to_color(const char *color) { + if (strlen(color) < 6 || color[0] != '#') { + ELOG("Could not parse color: %s\n", color); + return draw_util_hex_to_color("#A9A9A9"); + } + char alpha[2]; if (strlen(color) == strlen("#rrggbbaa")) { alpha[0] = color[7];