]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix crash in DoH on empty query string in GET requests
authorArtem Boldariev <artem@boldariev.com>
Tue, 13 Jul 2021 12:44:15 +0000 (15:44 +0300)
committerArtem Boldariev <artem@boldariev.com>
Tue, 13 Jul 2021 13:53:51 +0000 (16:53 +0300)
An unhandled code path left GET query string data uninitialised (equal
to NULL) and led to a crash during the requests' base64 data
decoding. This commit fixes that.

lib/isc/netmgr/http.c

index af0739cbe4c8164ad4cd2acd8a5e0c0bf85b36a2..a51dbf233ebfe37ebdd7b46daef5a9a458907238 100644 (file)
@@ -1706,6 +1706,11 @@ server_handle_path_header(isc_nmsocket_t *socket, const uint8_t *value,
                socket->h2.request_path = NULL;
                return (ISC_HTTP_ERROR_NOT_FOUND);
        }
+       /* The spec does not mention which value the query string for POST
+        * should have. For GET we use its value to decode a DNS message
+        * from it, for POST the message is transferred in the body of the
+        * request. Taking it into account, it is much safer to treat POST
+        * requests with query strings as malformed ones. */
        if (qstr != NULL) {
                const char *dns_value = NULL;
                size_t dns_value_len = 0;
@@ -1734,6 +1739,9 @@ server_handle_path_header(isc_nmsocket_t *socket, const uint8_t *value,
                } else {
                        return (ISC_HTTP_ERROR_BAD_REQUEST);
                }
+       } else if (qstr == NULL && socket->h2.request_type == ISC_HTTP_REQ_GET)
+       {
+               return (ISC_HTTP_ERROR_BAD_REQUEST);
        }
        return (ISC_HTTP_ERROR_SUCCESS);
 }