From 36e6cdcddf6eddeecde195fd3feef5515e02b03a Mon Sep 17 00:00:00 2001 From: kristapsdz Date: Fri, 27 Mar 2020 20:19:54 +0000 Subject: [PATCH] When reaching the hard-coded limit to JSON scope stack size, return ENOMEM instead of aborting. --- kcgijson.h | 4 ++++ man/kjson_array_open.3 | 3 ++- man/kjson_obj_open.3 | 3 ++- man/kjson_string_open.3 | 3 ++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kcgijson.h b/kcgijson.h index cb9a560..1f3501b 100644 --- a/kcgijson.h +++ b/kcgijson.h @@ -39,6 +39,10 @@ enum kjsontype { KJSON_STRING }; +/* + * The maximum number of JSON scopes allowed. + * Once this has been reached, new scopes will return KCGI_ENOMEM. + */ #define KJSON_STACK_MAX 128 struct kjsonscope { diff --git a/man/kjson_array_open.3 b/man/kjson_array_open.3 index 2a90d3b..56680dd 100644 --- a/man/kjson_array_open.3 +++ b/man/kjson_array_open.3 @@ -72,7 +72,8 @@ indicating the error state. .It Dv KCGI_OK Success (not an error). .It Dv KCGI_ENOMEM -Internal memory allocation failure. +Internal memory allocation failure, including reaching the maximum +number of possible JSON scopes. .It Dv KCGI_HUP The output connection has been terminated. For FastCGI connections, the current connection should be released with diff --git a/man/kjson_obj_open.3 b/man/kjson_obj_open.3 index 631b6a6..b20f06f 100644 --- a/man/kjson_obj_open.3 +++ b/man/kjson_obj_open.3 @@ -72,7 +72,8 @@ indicating the error state. .It Dv KCGI_OK Success (not an error). .It Dv KCGI_ENOMEM -Internal memory allocation failure. +Internal memory allocation failure, including reaching the maximum +number of possible JSON scopes. .It Dv KCGI_HUP The output connection has been terminated. For FastCGI connections, the current connection should be released with diff --git a/man/kjson_string_open.3 b/man/kjson_string_open.3 index e419383..7b8ebc1 100644 --- a/man/kjson_string_open.3 +++ b/man/kjson_string_open.3 @@ -73,7 +73,8 @@ indicating the error state. .It Dv KCGI_OK Success (not an error). .It Dv KCGI_ENOMEM -Internal memory allocation failure. +Internal memory allocation failure, including reaching the maximum +number of possible JSON scopes. .It Dv KCGI_HUP The output connection has been terminated. For FastCGI connections, the current connection should be released with