From f873bcc4e1b2d39edb9ca91ea60db24e6b6e42f2 Mon Sep 17 00:00:00 2001 From: Jason Nader Date: Mon, 18 Oct 2021 18:41:11 +0900 Subject: [PATCH] swaymsg: use INT_MAX max JSON depth when parsing IPC response Same reasoning as fe11caeac946cecda491d592044a6b9519ef2035. Without this, swaymsg would fail with a cryptic error message when the JSON was nested too deep. --- swaymsg/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/swaymsg/main.c b/swaymsg/main.c index 574d3b75..ce5d7d71 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -1,4 +1,5 @@ #define _POSIX_C_SOURCE 200809L +#include #include #include #include @@ -480,7 +481,9 @@ int main(int argc, char **argv) { char *resp = ipc_single_command(socketfd, type, command, &len); // pretty print the json - json_object *obj = json_tokener_parse(resp); + json_tokener *tok = json_tokener_new_ex(INT_MAX); + json_object *obj = json_tokener_parse_ex(tok, resp, -1); + json_tokener_free(tok); if (obj == NULL) { if (!quiet) { fprintf(stderr, "ERROR: Could not parse json response from ipc. " @@ -517,7 +520,9 @@ int main(int argc, char **argv) { break; } - json_object *obj = json_tokener_parse(reply->payload); + json_tokener *tok = json_tokener_new_ex(INT_MAX); + json_object *obj = json_tokener_parse_ex(tok, reply->payload, -1); + json_tokener_free(tok); if (obj == NULL) { if (!quiet) { fprintf(stderr, "ERROR: Could not parse json response from"