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.
This commit is contained in:
Tudor Brindus 2021-03-21 17:14:16 -04:00
parent 152a559e30
commit fe11caeac9

View file

@ -547,9 +547,14 @@ bool handle_ipc_readable(struct swaybar *bar) {
return false; return false;
} }
json_object *result = json_tokener_parse(resp->payload); json_tokener *tok = json_tokener_new_ex(INT_MAX);
if (!result) { json_object *result = json_tokener_parse_ex(tok, resp->payload, -1);
sway_log(SWAY_ERROR, "failed to parse payload as json"); enum json_tokener_error err = json_tokener_get_error(tok);
json_tokener_free(tok);
if (err != json_tokener_success) {
sway_log(SWAY_ERROR, "failed to parse payload as json: %s",
json_tokener_error_desc(err));
free_ipc_response(resp); free_ipc_response(resp);
return false; return false;
} }