2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

DoH: ensure that server_send_error_response() is used properly

The server_send_error_response() function is supposed to be used only
in case of failures and never in case of legitimate requests. Ensure
that ISC_HTTP_ERROR_SUCCESS is never passed there by mistake.
This commit is contained in:
Artem Boldariev
2022-01-14 14:14:53 +02:00
parent a38b4945c1
commit ca9fe3559a

View File

@@ -1941,7 +1941,6 @@ static struct http_error_responses {
const nghttp2_nv header;
const char *desc;
} error_responses[] = {
MAKE_ERROR_REPLY(ISC_HTTP_ERROR_SUCCESS, 200, "OK"),
MAKE_ERROR_REPLY(ISC_HTTP_ERROR_BAD_REQUEST, 400, "Bad Request"),
MAKE_ERROR_REPLY(ISC_HTTP_ERROR_NOT_FOUND, 404, "Not Found"),
MAKE_ERROR_REPLY(ISC_HTTP_ERROR_PAYLOAD_TOO_LARGE, 413,
@@ -1979,7 +1978,11 @@ log_server_error_response(const isc_nmsocket_t *socket,
static isc_result_t
server_send_error_response(const isc_http_error_responses_t error,
nghttp2_session *ngsession, isc_nmsocket_t *socket) {
void *base = isc_buffer_base(&socket->h2.rbuf);
void *base;
REQUIRE(error != ISC_HTTP_ERROR_SUCCESS);
base = isc_buffer_base(&socket->h2.rbuf);
if (base != NULL) {
isc_mem_free(socket->h2.session->mctx, base);
isc_buffer_initnull(&socket->h2.rbuf);