aboutsummaryrefslogtreecommitdiff
path: root/src/json
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-07-18 14:51:32 +0200
committerChristian Grothoff <christian@grothoff.org>2021-07-18 14:51:32 +0200
commit24433cf8d1241991b5a264ef81dc26868b50b90e (patch)
tree661dd841e61c869ca726b2d774d4109748b1bd27 /src/json
parent558a889bc8609ef99774b927a9b4ba780b3cbb1d (diff)
downloadgnunet-24433cf8d1241991b5a264ef81dc26868b50b90e.tar.gz
gnunet-24433cf8d1241991b5a264ef81dc26868b50b90e.zip
fail nicely if encoded text would be way too large
Diffstat (limited to 'src/json')
-rw-r--r--src/json/json_generator.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/json/json_generator.c b/src/json/json_generator.c
index 5806eb174..0c513ca9d 100644
--- a/src/json/json_generator.c
+++ b/src/json/json_generator.c
@@ -42,7 +42,14 @@ GNUNET_JSON_from_data (const void *data,
42 char *buf; 42 char *buf;
43 json_t *json; 43 json_t *json;
44 44
45 buf = GNUNET_STRINGS_data_to_string_alloc (data, size); 45 if ((size * 8 + 4) / 5 + 1 >=
46 GNUNET_MAX_MALLOC_CHECKED)
47 {
48 GNUNET_break (0);
49 return NULL;
50 }
51 buf = GNUNET_STRINGS_data_to_string_alloc (data,
52 size);
46 json = json_string (buf); 53 json = json_string (buf);
47 GNUNET_free (buf); 54 GNUNET_free (buf);
48 GNUNET_break (NULL != json); 55 GNUNET_break (NULL != json);
@@ -201,5 +208,4 @@ GNUNET_JSON_from_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *sig)
201} 208}
202 209
203 210
204
205/* End of json/json_generator.c */ 211/* End of json/json_generator.c */