]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/http: ensure missing variable in URI is treated as error
authorTomas Krizek <tomas.krizek@nic.cz>
Wed, 30 Jun 2021 20:43:11 +0000 (22:43 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 29 Jul 2021 12:03:10 +0000 (14:03 +0200)
daemon/http.c

index e6b7d71503daf892be5c2597a8f418c560d0c098..45d74a5b5d7aea951241ae96f547782524af87b4 100644 (file)
@@ -175,6 +175,10 @@ static int check_uri(const char* uri_path)
 
        if (ret) /* no endpoint found */
                return -1;
+
+       /* FIXME This also passes for GET when no variables are provided.
+        * Fixing it doesn't seem straightforward, since :method may not be
+        * known by the time check_uri() is called... */
        if (endpoint_len == strlen(path) - 1) /* done for POST method */
                return 0;
 
@@ -216,7 +220,7 @@ static int process_uri_path(struct http_ctx *ctx, const char* path, int32_t stre
        uint8_t *dest;
 
        if (!beg)  /* No dns variable in path. */
-               return 0;
+               return -1;
 
        beg += sizeof(key) - 1;
        end = strchr(beg, '&');
@@ -451,6 +455,7 @@ static int on_frame_recv_callback(nghttp2_session *h2, const nghttp2_frame *fram
                if (ctx->current_method == HTTP_METHOD_GET) {
                        if (process_uri_path(ctx, ctx->uri_path, stream_id) < 0) {
                                refuse_stream(h2, stream_id);
+                               return 0;  /* End processing - don't submit to wirebuffer. */
                        }
                }
                ctx->headers = NULL;  // Success -> transfer ownership to stream (waiting in wirebuffer)