diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-12-08 18:12:28 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-12-08 18:12:28 +0100 |
commit | 7e84b5570adeaa027f8c7861caf6af7943edcd0b (patch) | |
tree | ed861b2116ba354321829da3fcb2dc1f8ee93cee /src/exchange/taler-exchange-httpd.c | |
parent | ed7379d235b39d71e4cd94f90b52627c32c6d8e7 (diff) | |
download | exchange-7e84b5570adeaa027f8c7861caf6af7943edcd0b.tar.gz exchange-7e84b5570adeaa027f8c7861caf6af7943edcd0b.tar.bz2 exchange-7e84b5570adeaa027f8c7861caf6af7943edcd0b.zip |
fix error handling for very large uploads, fix re-generation of /keys response after Expires expires
Diffstat (limited to 'src/exchange/taler-exchange-httpd.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 57c965189..58e9b572a 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -1003,6 +1003,36 @@ handle_mhd_request (void *cls, "illegal incoming correlation ID\n"); correlation_id = NULL; } + + /* Check if upload is in bounds */ + if (0 == strcasecmp (method, + MHD_HTTP_METHOD_POST)) + { + 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; + char dummy; + + if (1 != sscanf (cl, + "%llu%c", + &cv, + &dummy)) + { + /* Not valid HTTP request, just close connection. */ + GNUNET_break_op (0); + return MHD_NO; + } + if (cv > TALER_MHD_REQUEST_BUFFER_MAX) + return TALER_MHD_reply_request_too_large (connection); + } + } } GNUNET_async_scope_enter (&rc->async_scope_id, |