aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrestis Floros <orestisflo@gmail.com>2020-04-10 11:38:19 +0200
committerOrestis Floros <orestisflo@gmail.com>2020-04-10 11:38:19 +0200
commit91ec14f2bc59cac6225b60532b8f7e81e6492f63 (patch)
treea498826bb35ec50559e4ac6ff87352648241500b
parentc46fdc8363825d1d2fe89fabdababf72706bcc12 (diff)
downloadi3-91ec14f2bc59cac6225b60532b8f7e81e6492f63.tar.gz
i3-91ec14f2bc59cac6225b60532b8f7e81e6492f63.zip
Fix SEGFAULT when i3bar receives invalid input
Fixes #3844
-rw-r--r--i3bar/src/child.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/i3bar/src/child.c b/i3bar/src/child.c
index b145e5d5..56961fc8 100644
--- a/i3bar/src/child.c
+++ b/i3bar/src/child.c
@@ -194,6 +194,11 @@ static int stdin_map_key(void *context, const unsigned char *key, size_t len) {
static int stdin_boolean(void *context, int val) {
parser_ctx *ctx = context;
+
+ if (!ctx->last_map_key) {
+ return 0;
+ }
+
if (strcasecmp(ctx->last_map_key, "urgent") == 0) {
ctx->block.urgent = val;
return 1;
@@ -208,6 +213,11 @@ static int stdin_boolean(void *context, int val) {
static int stdin_string(void *context, const unsigned char *val, size_t len) {
parser_ctx *ctx = context;
+
+ if (!ctx->last_map_key) {
+ return 0;
+ }
+
if (strcasecmp(ctx->last_map_key, "full_text") == 0) {
ctx->block.full_text = i3string_from_markup_with_length((const char *)val, len);
return 1;
@@ -260,6 +270,11 @@ static int stdin_string(void *context, const unsigned char *val, size_t len) {
static int stdin_integer(void *context, long long val) {
parser_ctx *ctx = context;
+
+ if (!ctx->last_map_key) {
+ return 0;
+ }
+
if (strcasecmp(ctx->last_map_key, "min_width") == 0) {
ctx->block.min_width = (uint32_t)val;
return 1;