diff options
author | Ingo Bürk <admin@airblader.de> | 2020-04-10 14:00:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-10 14:00:51 +0200 |
commit | e2b2a286251481abd83e72127a6f486753756c7e (patch) | |
tree | b33bb275ce6de17822fb5dff6511cac637a0e5a1 | |
parent | 312d3dfbd35d1c8a02756f077e58b20021c11a3a (diff) | |
parent | 91ec14f2bc59cac6225b60532b8f7e81e6492f63 (diff) | |
download | i3-e2b2a286251481abd83e72127a6f486753756c7e.tar.gz i3-e2b2a286251481abd83e72127a6f486753756c7e.zip |
Merge pull request #4004 from orestisfl/i3bar-segfault
Fix SEGFAULT when i3bar receives invalid input
-rw-r--r-- | i3bar/src/child.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 9c6325c1..e56145fa 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -196,6 +196,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; @@ -210,6 +215,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; @@ -262,6 +272,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; |