diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c771a92b..6d3aa714 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -237,7 +237,7 @@ jobs: --disable-shared \ --enable-static \ --enable-all-static \ - CFLAGS="-O2 -pthread -fstack-protector-all" + CFLAGS="-O2 -pthread -fstack-protector-all -Wl,--stack,8388608" make -j$(nproc) file ./jq.exe cp ./jq.exe jq-${{ env.SUFFIX }}.exe diff --git a/src/jv_print.c b/src/jv_print.c index 791af179..f717d079 100644 --- a/src/jv_print.c +++ b/src/jv_print.c @@ -17,7 +17,7 @@ #include "jv_private.h" #ifndef MAX_PRINT_DEPTH -#define MAX_PRINT_DEPTH (256) +#define MAX_PRINT_DEPTH (10000) #endif #define ESC "\033" diff --git a/tests/jq.test b/tests/jq.test index 14d98ba1..2471379d 100644 --- a/tests/jq.test +++ b/tests/jq.test @@ -2515,3 +2515,22 @@ strflocaltime("" | ., @uri) 0 "" "" + +# regression tests for #3413 +# upper range bounds should be in sync with the constants defined at +# src/jv_parse.c:#define MAX_PARSING_DEPTH (N) +# src/jv_print.c:#define MAX_PRINT_DEPTH (N) +# (N-1) +reduce range(9999) as $_ ([];[.]) | tojson | fromjson | flatten +null +[] + +# (N) +reduce range(10000) as $_ ([];[.]) | tojson | try (fromjson) catch . | (contains("") | not) and contains("Exceeds depth limit for parsing") +null +true + +# (N+1) +reduce range(10001) as $_ ([];[.]) | tojson | contains("") +null +true