diff --git a/src/main.c b/src/main.c index a316f63c..90f5f2af 100644 --- a/src/main.c +++ b/src/main.c @@ -21,6 +21,10 @@ extern void jv_tsd_dtoa_ctx_init(); #endif +#ifdef HAVE_LIBONIG +#include +#endif + #if !defined(HAVE_ISATTY) && defined(HAVE__ISATTY) #undef isatty #define isatty _isatty @@ -298,6 +302,13 @@ int main(int argc, char* argv[]) { (void) setlocale(LC_ALL, ""); #endif +#ifdef HAVE_LIBONIG + // use a lower regex parse depth limit than the default (4096) to protect + // from stack-overflows + // https://github.com/jqlang/jq/security/advisories/GHSA-f946-j5j2-4w5m + onig_set_parse_depth_limit(1024); +#endif + #ifdef __OpenBSD__ if (pledge("stdio rpath", NULL) == -1) { perror("pledge");