twister

HTTP fault injector for testing
Log | Files | Refs | README | LICENSE

commit 5edfaa88e348dca84658fbdd2f9cc526c4310fe8
parent 411d8e66236ad9748a944124e6d4e2ea30de8f84
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Wed, 12 Jun 2019 22:16:36 +0200

check Content-Type before parsing

Diffstat:
Msrc/twister/taler-twister-service.c | 33+++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c @@ -1519,22 +1519,31 @@ create_response (void *cls, (con, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_ENCODING); + if ((NULL != ce) && (0 == strcmp ("deflate", ce))) GNUNET_assert (Z_OK == inflate_data (hr)); - json_error_t error; - hr->json = json_loadb (hr->io_buf, - hr->io_len, - JSON_DECODE_ANY, - &error); - if (NULL == hr->json) + ce = MHD_lookup_connection_value + (con, + MHD_HEADER_KIND, + MHD_HTTP_HEADER_CONTENT_TYPE); + + if ((NULL != ce) && (0 == strcmp ("application/json", ce))) { - TALER_LOG_ERROR - ("Could not parse JSON from client: %s (%s)\n", - error.text, - error.source); - /* Quick and dirty. */ - return MHD_NO; + json_error_t error; + hr->json = json_loadb (hr->io_buf, + hr->io_len, + JSON_DECODE_ANY, + &error); + if (NULL == hr->json) + { + TALER_LOG_ERROR + ("Could not parse JSON from client: %s (%s)\n", + error.text, + error.source); + /* Quick and dirty. */ + return MHD_NO; + } } } }