]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
json: decrease DEPTH_MAX to 4k
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 Nov 2018 00:05:59 +0000 (09:05 +0900)
committerLennart Poettering <lennart@poettering.net>
Wed, 14 Nov 2018 09:44:18 +0000 (10:44 +0100)
This makes DEPTH_MAX lower value, as test-json fails with stack
overflow.

Note that the test can pass with 8k, but for safety, here set to 4k.

Fixes #10738.

src/basic/json.c

index 8bbb69674a4a55bb3eea1bdc5b2e073d0f089ca5..53ac80a6c6462afff31414d1f90e5a35a96387cb 100644 (file)
 #include "terminal-util.h"
 #include "utf8.h"
 
-/* Refuse putting together variants with a larger depth than 16K by default (as a protection against overflowing stacks
+/* Refuse putting together variants with a larger depth than 4K by default (as a protection against overflowing stacks
  * if code processes JSON objects recursively. Note that we store the depth in an uint16_t, hence make sure this
- * remains under 2^16. */
-#define DEPTH_MAX (16U*1024U)
+ * remains under 2^16.
+ * The value was 16k, but it was discovered to be too high on llvm/x86-64. See also the issue #10738. */
+#define DEPTH_MAX (4U*1024U)
 assert_cc(DEPTH_MAX <= UINT16_MAX);
 
 typedef struct JsonSource {