merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit ad12ba186b99150b0f2fce52fed550c337d22f2e
parent 6cf8a87be1ec8cb846a361d35b68c5602e174fa5
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat,  6 May 2023 19:45:33 +0200

use new TALER_MHD_check_content_length() macro

Diffstat:
Msrc/backend/taler-merchant-httpd.c | 37++++---------------------------------
1 file changed, 4 insertions(+), 33 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -1667,39 +1667,10 @@ url_handler (void *cls, MHD_HTTP_METHOD_PATCH)) ); if (hc->has_body) { - const char *cl; - - /* Maybe check for maximum upload size - and refuse requests if they are just too big. */ - cl = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_CONTENT_LENGTH); - if (NULL != cl) - { - unsigned long long cv; - size_t mul = hc->rh->max_upload; - char dummy; - - if (0 == mul) - mul = DEFAULT_MAX_UPLOAD_SIZE; - if (1 != sscanf (cl, - "%llu%c", - &cv, - &dummy)) - { - /* Not valid HTTP request, just close connection. */ - GNUNET_break_op (0); - return MHD_NO; - } - if (cv > mul) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_PAYLOAD_TOO_LARGE, - TALER_EC_GENERIC_UPLOAD_EXCEEDS_LIMIT, - cl); - } - } + TALER_MHD_check_content_length (connection, + 0 == hc->rh->max_upload + ? DEFAULT_MAX_UPLOAD_SIZE + : hc->rh->max_upload); GNUNET_break (NULL == hc->request_body); /* can't have it already */ } return MHD_YES; /* wait for MHD to call us again */