From fedff2cd6c3b83a5f59e331201a4b0673174d0f7 Mon Sep 17 00:00:00 2001 From: Artem Boldariev Date: Mon, 5 Jul 2021 16:48:54 +0300 Subject: [PATCH] Return "Bad Request" (400) in a case of Base64 decoding error This error code fits better than the more generic "Internal Server Error" (500) which implies that the problem is on the server. Also, do not end the whole HTTP/2 session on a bad request. --- lib/isc/netmgr/http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index 723dd57e7e..a21c882e86 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -2036,7 +2036,7 @@ server_on_request_recv(nghttp2_session *ngsession, if (isc_base64_decodestring(socket->h2.query_data, &decoded_buf) != ISC_R_SUCCESS) { - code = ISC_HTTP_ERROR_GENERIC; + code = ISC_HTTP_ERROR_BAD_REQUEST; goto error; } isc__buffer_usedregion(&decoded_buf, &data); @@ -2055,7 +2055,7 @@ server_on_request_recv(nghttp2_session *ngsession, error: result = server_send_error_response(code, ngsession, socket); if (result != ISC_R_SUCCESS) { - return (NGHTTP2_ERR_CALLBACK_FAILURE); + return (NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE); } return (0); }