diff options
author | Jason Nader <jason.nader@protonmail.com> | 2021-10-18 18:41:11 +0900 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-10-18 14:20:24 +0200 |
commit | f873bcc4e1b2d39edb9ca91ea60db24e6b6e42f2 (patch) | |
tree | 06928f95ced2b6d42671243cdab3a46bfed9c5fb | |
parent | config.in: use swaynag -B instead of -b (diff) | |
download | sway-f873bcc4e1b2d39edb9ca91ea60db24e6b6e42f2.tar.gz sway-f873bcc4e1b2d39edb9ca91ea60db24e6b6e42f2.tar.zst sway-f873bcc4e1b2d39edb9ca91ea60db24e6b6e42f2.zip |
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.
-rw-r--r-- | swaymsg/main.c | 9 |
1 files 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 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <limits.h> | ||
2 | #include <stdio.h> | 3 | #include <stdio.h> |
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
4 | #include <string.h> | 5 | #include <string.h> |
@@ -480,7 +481,9 @@ int main(int argc, char **argv) { | |||
480 | char *resp = ipc_single_command(socketfd, type, command, &len); | 481 | char *resp = ipc_single_command(socketfd, type, command, &len); |
481 | 482 | ||
482 | // pretty print the json | 483 | // pretty print the json |
483 | json_object *obj = json_tokener_parse(resp); | 484 | json_tokener *tok = json_tokener_new_ex(INT_MAX); |
485 | json_object *obj = json_tokener_parse_ex(tok, resp, -1); | ||
486 | json_tokener_free(tok); | ||
484 | if (obj == NULL) { | 487 | if (obj == NULL) { |
485 | if (!quiet) { | 488 | if (!quiet) { |
486 | fprintf(stderr, "ERROR: Could not parse json response from ipc. " | 489 | fprintf(stderr, "ERROR: Could not parse json response from ipc. " |
@@ -517,7 +520,9 @@ int main(int argc, char **argv) { | |||
517 | break; | 520 | break; |
518 | } | 521 | } |
519 | 522 | ||
520 | json_object *obj = json_tokener_parse(reply->payload); | 523 | json_tokener *tok = json_tokener_new_ex(INT_MAX); |
524 | json_object *obj = json_tokener_parse_ex(tok, reply->payload, -1); | ||
525 | json_tokener_free(tok); | ||
521 | if (obj == NULL) { | 526 | if (obj == NULL) { |
522 | if (!quiet) { | 527 | if (!quiet) { |
523 | fprintf(stderr, "ERROR: Could not parse json response from" | 528 | fprintf(stderr, "ERROR: Could not parse json response from" |