]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/http: fix assertion fail when data frame is recieved
authorLukáš Ježek <lukas.jezek@nic.cz>
Fri, 12 Mar 2021 12:36:37 +0000 (13:36 +0100)
committerLukáš Ježek <lukas.jezek@nic.cz>
Fri, 12 Mar 2021 13:45:14 +0000 (14:45 +0100)
daemon/http.c

index b1ee725be94db663b43270c52638ae4a22a47d4c..b0417635029fd32e2b65eb477caf16a8ab4c85ea 100644 (file)
@@ -536,13 +536,10 @@ static int data_chunk_recv_callback(nghttp2_session *h2, uint8_t flags, int32_t
        struct http_ctx *ctx = (struct http_ctx *)user_data;
        ssize_t remaining;
        ssize_t required;
-       assert(ctx->current_stream);
-       bool is_first = queue_len(ctx->streams) == 0 || queue_tail(ctx->streams) != ctx->current_stream->stream_id;
+       bool is_first;
 
-       if (ctx->current_stream->stream_id != stream_id) {
-               kr_log_verbose(
-                       "[http] stream %d incomplete\n",
-                       ctx->current_stream->stream_id);
+       if (ctx->current_stream == NULL || ctx->current_stream->stream_id != stream_id) {
+               kr_log_verbose("[http] incomplete stream\n");
                if (!set_error_status(ctx, stream_id, 501, "incomplete stream"))
                        return NGHTTP2_ERR_CALLBACK_FAILURE;
                return 0;
@@ -550,6 +547,8 @@ static int data_chunk_recv_callback(nghttp2_session *h2, uint8_t flags, int32_t
 
        remaining = ctx->buf_size - ctx->submitted - ctx->buf_pos;
        required = len;
+
+       is_first = queue_len(ctx->streams) == 0 || queue_tail(ctx->streams) != ctx->current_stream->stream_id;
        /* First data chunk of the new stream */
        if (is_first)
                required += sizeof(uint16_t);