From: Orestis Floros Date: Thu, 6 Sep 2018 11:54:27 +0000 (+0300) Subject: tree_append_json: Allow strings that are not valid UTF8 X-Git-Tag: 4.16~45^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=be6faa31617e3da2fc5c4af43821e9d76dc6d5ac;p=i3%2Fi3 tree_append_json: Allow strings that are not valid UTF8 Fixes #3156. I couldn't reproduce the problem in a "natural" way so I cheated: 1. Start i3 with gdb 2. Set breakpoing on tree_restore 3. Run, open window, i3-msg restart 5. Open the file in *path with a hex editor 6. Edit the "name" field of the window and insert bytes that are not valid UTF8 7. Continue After parsing fails, all nodes including croot are incomplete, meaning they have to be deleted. We can't recover in any reasonable way so we have to allow non-UTF8 characters to avoid this situation altogether. --- diff --git a/src/load_layout.c b/src/load_layout.c index 5f391ad7..d2ad4e87 100644 --- a/src/load_layout.c +++ b/src/load_layout.c @@ -611,6 +611,10 @@ void tree_append_json(Con *con, const char *buf, const size_t len, char **errorm yajl_config(hand, yajl_allow_comments, true); /* Allow multiple values, i.e. multiple nodes to attach */ yajl_config(hand, yajl_allow_multiple_values, true); + /* Allow strings that are not valid UTF8. Could be possible if a container + * name contains such characters. If yajl stops parsing because of this, an + * in-place restart could fail: see #3156. */ + yajl_config(hand, yajl_dont_validate_strings, true); json_node = con; to_focus = NULL; incomplete = 0;