diff options
author | 2021-03-21 17:14:16 -0400 | |
---|---|---|
committer | 2021-03-21 23:34:07 +0100 | |
commit | 47f1f9b63ea04ee5d520f36d9a0ef5de04921816 (patch) | |
tree | 6a9301d7d49885d693677803de228422d98adc39 | |
parent | idle_inhibit: Store wlr inhibitor instead of view (diff) | |
download | sway-47f1f9b63ea04ee5d520f36d9a0ef5de04921816.tar.gz sway-47f1f9b63ea04ee5d520f36d9a0ef5de04921816.tar.zst sway-47f1f9b63ea04ee5d520f36d9a0ef5de04921816.zip |
swaybar: use INT_MAX max JSON depth when parsing IPC response
There's no inherent limit on the nesting Sway can generate, and the
default used by `json_tokener_new`, 32, can plausibly be hit during
regular usage.
Fixes #6115.
-rw-r--r-- | swaybar/ipc.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 6bbe9408..05238d8b 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c | |||
@@ -547,9 +547,14 @@ bool handle_ipc_readable(struct swaybar *bar) { | |||
547 | return false; | 547 | return false; |
548 | } | 548 | } |
549 | 549 | ||
550 | json_object *result = json_tokener_parse(resp->payload); | 550 | json_tokener *tok = json_tokener_new_ex(INT_MAX); |
551 | if (!result) { | 551 | json_object *result = json_tokener_parse_ex(tok, resp->payload, -1); |
552 | sway_log(SWAY_ERROR, "failed to parse payload as json"); | 552 | enum json_tokener_error err = json_tokener_get_error(tok); |
553 | json_tokener_free(tok); | ||
554 | |||
555 | if (err != json_tokener_success) { | ||
556 | sway_log(SWAY_ERROR, "failed to parse payload as json: %s", | ||
557 | json_tokener_error_desc(err)); | ||
553 | free_ipc_response(resp); | 558 | free_ipc_response(resp); |
554 | return false; | 559 | return false; |
555 | } | 560 | } |