mirror of
https://gitea.invidious.io/iv-org/litespeed-quic.git
synced 2024-08-15 00:53:43 +00:00
Release 2.13.2
- [BUGFIX] Use of new lsxpack_header API's hsi_prepare_decode().
This commit is contained in:
parent
02a4ee50be
commit
992bbcdba6
11 changed files with 63 additions and 57 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2020-03-13
|
||||||
|
- 2.13.2
|
||||||
|
- [BUGFIX] Use of new lsxpack_header API's hsi_prepare_decode().
|
||||||
|
|
||||||
2020-03-12
|
2020-03-12
|
||||||
- 2.13.1
|
- 2.13.1
|
||||||
- [API] Use lsxpack_header structure to process incoming headers.
|
- [API] Use lsxpack_header structure to process incoming headers.
|
||||||
|
|
|
@ -1421,11 +1421,16 @@ fields yourself. In that case, the header set must be "read" from the stream vi
|
||||||
.. member:: struct lsxpack_header * (*hsi_prepare_decode)(void *hdr_set, struct lsxpack_header *hdr, size_t space)
|
.. member:: struct lsxpack_header * (*hsi_prepare_decode)(void *hdr_set, struct lsxpack_header *hdr, size_t space)
|
||||||
|
|
||||||
Return a header set prepared for decoding. If ``hdr`` is NULL, this
|
Return a header set prepared for decoding. If ``hdr`` is NULL, this
|
||||||
means return a new structure with at least `space' bytes available
|
means return a new structure with at least ``space`` bytes available
|
||||||
in the decoder buffer. If `hdr' is not NULL, it means there was not
|
in the decoder buffer. On success, a newly prepared header is
|
||||||
enough decoder buffer and it must be increased by ``space`` bytes.
|
returned.
|
||||||
|
|
||||||
If NULL is returned the header set is discarded.
|
If ``hdr`` is not NULL, it means there was not enough decoder buffer
|
||||||
|
and it must be increased to at least ``space`` bytes. ``buf``, ``val_len``,
|
||||||
|
and ``name_offset`` member of the ``hdr`` structure may change. On
|
||||||
|
success, the return value is the same as ``hdr``.
|
||||||
|
|
||||||
|
If NULL is returned, the space cannot be allocated.
|
||||||
|
|
||||||
.. member:: int (*hsi_process_header)(void *hdr_set, struct lsxpack_header *hdr)
|
.. member:: int (*hsi_process_header)(void *hdr_set, struct lsxpack_header *hdr)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ author = u'LiteSpeed Technologies'
|
||||||
# The short X.Y version
|
# The short X.Y version
|
||||||
version = u'2.13'
|
version = u'2.13'
|
||||||
# The full version, including alpha/beta/rc tags
|
# The full version, including alpha/beta/rc tags
|
||||||
release = u'2.13.1'
|
release = u'2.13.2'
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
||||||
|
|
||||||
#define LSQUIC_MAJOR_VERSION 2
|
#define LSQUIC_MAJOR_VERSION 2
|
||||||
#define LSQUIC_MINOR_VERSION 13
|
#define LSQUIC_MINOR_VERSION 13
|
||||||
#define LSQUIC_PATCH_VERSION 1
|
#define LSQUIC_PATCH_VERSION 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Engine flags:
|
* Engine flags:
|
||||||
|
@ -874,10 +874,15 @@ struct lsquic_hset_if
|
||||||
/**
|
/**
|
||||||
* Return a header set prepared for decoding. If `hdr' is NULL, this
|
* Return a header set prepared for decoding. If `hdr' is NULL, this
|
||||||
* means return a new structure with at least `space' bytes available
|
* means return a new structure with at least `space' bytes available
|
||||||
* in the decoder buffer. If `hdr' is not NULL, it means there was not
|
* in the decoder buffer. On success, a newly prepared header is
|
||||||
* enough decoder buffer and it must be increased by `space' bytes.
|
* returned.
|
||||||
*
|
*
|
||||||
* If NULL is returned the header set is discarded.
|
* If `hdr' is not NULL, it means there was not enough decoder buffer
|
||||||
|
* and it must be increased to at least `space' bytes. `buf', `val_len',
|
||||||
|
* and `name_offset' member of the `hdr' structure may change. On
|
||||||
|
* success, the return value is the same as `hdr'.
|
||||||
|
*
|
||||||
|
* If NULL is returned, the space cannot be allocated.
|
||||||
*/
|
*/
|
||||||
struct lsxpack_header *
|
struct lsxpack_header *
|
||||||
(*hsi_prepare_decode)(void *hdr_set,
|
(*hsi_prepare_decode)(void *hdr_set,
|
||||||
|
|
|
@ -520,7 +520,7 @@ decode_and_pass_payload (struct lsquic_frame_reader *fr)
|
||||||
struct uncompressed_headers *uh = NULL;
|
struct uncompressed_headers *uh = NULL;
|
||||||
void *hset = NULL;
|
void *hset = NULL;
|
||||||
struct lsxpack_header *hdr = NULL;
|
struct lsxpack_header *hdr = NULL;
|
||||||
size_t extra = 0;
|
size_t req_space = 0;
|
||||||
|
|
||||||
hset = fr->fr_hsi_if->hsi_create_header_set(fr->fr_hsi_ctx,
|
hset = fr->fr_hsi_if->hsi_create_header_set(fr->fr_hsi_ctx,
|
||||||
READER_PUSH_PROMISE == fr->fr_state.reader_type);
|
READER_PUSH_PROMISE == fr->fr_state.reader_type);
|
||||||
|
@ -536,7 +536,7 @@ decode_and_pass_payload (struct lsquic_frame_reader *fr)
|
||||||
while (comp < end)
|
while (comp < end)
|
||||||
{
|
{
|
||||||
prepare:
|
prepare:
|
||||||
hdr = fr->fr_hsi_if->hsi_prepare_decode(hset, hdr, extra);
|
hdr = fr->fr_hsi_if->hsi_prepare_decode(hset, hdr, req_space);
|
||||||
if (!hdr)
|
if (!hdr)
|
||||||
{
|
{
|
||||||
err = FR_ERR_OTHER_ERROR;
|
err = FR_ERR_OTHER_ERROR;
|
||||||
|
@ -552,7 +552,7 @@ decode_and_pass_payload (struct lsquic_frame_reader *fr)
|
||||||
fr->fr_conn_stats->in.headers_uncomp += hdr->name_len +
|
fr->fr_conn_stats->in.headers_uncomp += hdr->name_len +
|
||||||
hdr->val_len;
|
hdr->val_len;
|
||||||
#endif
|
#endif
|
||||||
extra = 0;
|
req_space = 0;
|
||||||
hdr = NULL;
|
hdr = NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ decode_and_pass_payload (struct lsquic_frame_reader *fr)
|
||||||
}
|
}
|
||||||
else if (s == LSHPACK_ERR_MORE_BUF)
|
else if (s == LSHPACK_ERR_MORE_BUF)
|
||||||
{
|
{
|
||||||
extra = hdr->val_len;
|
req_space = hdr->val_len;
|
||||||
goto prepare;
|
goto prepare;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -3918,7 +3918,7 @@ synthesize_push_request (struct full_conn *conn, void *hset,
|
||||||
lsquic_http_header_t pseudo_headers[4];
|
lsquic_http_header_t pseudo_headers[4];
|
||||||
lsquic_http_headers_t all_headers[2];
|
lsquic_http_headers_t all_headers[2];
|
||||||
struct lsxpack_header *xhdr;
|
struct lsxpack_header *xhdr;
|
||||||
size_t extra;
|
size_t req_space;
|
||||||
|
|
||||||
if (!hset)
|
if (!hset)
|
||||||
{
|
{
|
||||||
|
@ -3973,9 +3973,9 @@ synthesize_push_request (struct full_conn *conn, void *hset,
|
||||||
header < all_headers[i].headers + all_headers[i].count;
|
header < all_headers[i].headers + all_headers[i].count;
|
||||||
++header)
|
++header)
|
||||||
{
|
{
|
||||||
extra = header->name.iov_len + header->value.iov_len + 4;
|
req_space = header->name.iov_len + header->value.iov_len + 4;
|
||||||
xhdr = conn->fc_enpub->enp_hsi_if->hsi_prepare_decode(hset,
|
xhdr = conn->fc_enpub->enp_hsi_if->hsi_prepare_decode(hset,
|
||||||
NULL, extra);
|
NULL, req_space);
|
||||||
if (!xhdr)
|
if (!xhdr)
|
||||||
{
|
{
|
||||||
st = -__LINE__;
|
st = -__LINE__;
|
||||||
|
|
|
@ -3282,7 +3282,7 @@ ietf_full_conn_ci_push_stream (struct lsquic_conn *lconn, void *hset,
|
||||||
int own_hset, stx_tab_id;
|
int own_hset, stx_tab_id;
|
||||||
unsigned char discard[2];
|
unsigned char discard[2];
|
||||||
struct lsxpack_header *xhdr;
|
struct lsxpack_header *xhdr;
|
||||||
size_t extra;
|
size_t req_space;
|
||||||
|
|
||||||
if (!ietf_full_conn_ci_is_push_enabled(lconn)
|
if (!ietf_full_conn_ci_is_push_enabled(lconn)
|
||||||
|| !lsquic_stream_can_push(dep_stream))
|
|| !lsquic_stream_can_push(dep_stream))
|
||||||
|
@ -3394,9 +3394,9 @@ ietf_full_conn_ci_push_stream (struct lsquic_conn *lconn, void *hset,
|
||||||
header < all_headers[i].headers + all_headers[i].count;
|
header < all_headers[i].headers + all_headers[i].count;
|
||||||
++header)
|
++header)
|
||||||
{
|
{
|
||||||
extra = header->name.iov_len + header->value.iov_len + 4;
|
req_space = header->name.iov_len + header->value.iov_len + 4;
|
||||||
xhdr = conn->ifc_enpub->enp_hsi_if->hsi_prepare_decode(hset,
|
xhdr = conn->ifc_enpub->enp_hsi_if->hsi_prepare_decode(hset,
|
||||||
NULL, extra);
|
NULL, req_space);
|
||||||
if (!xhdr)
|
if (!xhdr)
|
||||||
{
|
{
|
||||||
header_st = -__LINE__;
|
header_st = -__LINE__;
|
||||||
|
|
|
@ -507,40 +507,31 @@ h1h_finish_hset (struct header_writer_ctx *hwc)
|
||||||
|
|
||||||
|
|
||||||
static struct lsxpack_header *
|
static struct lsxpack_header *
|
||||||
h1h_prepare_decode (void *hset, struct lsxpack_header *xhdr, size_t extra_space)
|
h1h_prepare_decode (void *hset, struct lsxpack_header *xhdr, size_t req_space)
|
||||||
{
|
{
|
||||||
struct header_writer_ctx *const hwc = HWC_PTR(hset);
|
struct header_writer_ctx *const hwc = HWC_PTR(hset);
|
||||||
size_t min_space;
|
|
||||||
|
|
||||||
if (0 == extra_space)
|
if (0 == req_space)
|
||||||
min_space = 0x100;
|
req_space = 0x100;
|
||||||
else
|
|
||||||
min_space = extra_space;
|
|
||||||
|
|
||||||
if (xhdr)
|
if (req_space > MAX_HTTP1X_HEADERS_SIZE || req_space > LSXPACK_MAX_STRLEN)
|
||||||
{
|
|
||||||
assert(xhdr == &hwc->hwc_xhdr);
|
|
||||||
min_space += xhdr->val_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (min_space > MAX_HTTP1X_HEADERS_SIZE || min_space > LSXPACK_MAX_STRLEN)
|
|
||||||
{
|
{
|
||||||
LSQ_DEBUG("requested space for header is too large: %zd bytes",
|
LSQ_DEBUG("requested space for header is too large: %zd bytes",
|
||||||
min_space);
|
req_space);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (min_space > hwc->hwc_header_buf_nalloc)
|
if (req_space > hwc->hwc_header_buf_nalloc)
|
||||||
{
|
{
|
||||||
free(hwc->hwc_header_buf);
|
free(hwc->hwc_header_buf);
|
||||||
hwc->hwc_header_buf_nalloc = 0;
|
hwc->hwc_header_buf_nalloc = 0;
|
||||||
hwc->hwc_header_buf = malloc(min_space);
|
hwc->hwc_header_buf = malloc(req_space);
|
||||||
if (!hwc->hwc_header_buf)
|
if (!hwc->hwc_header_buf)
|
||||||
{
|
{
|
||||||
LSQ_DEBUG("cannot allocate %zd bytes", min_space);
|
LSQ_DEBUG("cannot allocate %zd bytes", req_space);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
hwc->hwc_header_buf_nalloc = min_space;
|
hwc->hwc_header_buf_nalloc = req_space;
|
||||||
}
|
}
|
||||||
|
|
||||||
lsxpack_header_prepare_decode(&hwc->hwc_xhdr, hwc->hwc_header_buf,
|
lsxpack_header_prepare_decode(&hwc->hwc_xhdr, hwc->hwc_header_buf,
|
||||||
|
|
|
@ -455,7 +455,7 @@ qdh_supply_hset_to_stream (struct qpack_dec_hdl *qdh,
|
||||||
void *hset;
|
void *hset;
|
||||||
struct cont_len cl;
|
struct cont_len cl;
|
||||||
struct lsxpack_header *xhdr;
|
struct lsxpack_header *xhdr;
|
||||||
size_t extra;
|
size_t req_space;
|
||||||
|
|
||||||
push_promise = lsquic_stream_header_is_pp(stream);
|
push_promise = lsquic_stream_header_is_pp(stream);
|
||||||
hset = hset_if->hsi_create_header_set(qdh->qdh_hsi_ctx, push_promise);
|
hset = hset_if->hsi_create_header_set(qdh->qdh_hsi_ctx, push_promise);
|
||||||
|
@ -473,11 +473,11 @@ qdh_supply_hset_to_stream (struct qpack_dec_hdl *qdh,
|
||||||
header = qlist->qhl_headers[i];
|
header = qlist->qhl_headers[i];
|
||||||
LSQ_DEBUG("%.*s: %.*s", header->qh_name_len, header->qh_name,
|
LSQ_DEBUG("%.*s: %.*s", header->qh_name_len, header->qh_name,
|
||||||
header->qh_value_len, header->qh_value);
|
header->qh_value_len, header->qh_value);
|
||||||
extra = header->qh_name_len + header->qh_value_len + 4;
|
req_space = header->qh_name_len + header->qh_value_len + 4;
|
||||||
xhdr = hset_if->hsi_prepare_decode(hset, NULL, extra);
|
xhdr = hset_if->hsi_prepare_decode(hset, NULL, req_space);
|
||||||
if (!xhdr)
|
if (!xhdr)
|
||||||
{
|
{
|
||||||
LSQ_DEBUG("prepare_decode(%zd) failed", extra);
|
LSQ_DEBUG("prepare_decode(%zd) failed", req_space);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
memcpy(xhdr->buf + xhdr->name_offset, header->qh_name,
|
memcpy(xhdr->buf + xhdr->name_offset, header->qh_name,
|
||||||
|
|
|
@ -1001,24 +1001,18 @@ hset_create (void *hsi_ctx, int is_push_promise)
|
||||||
|
|
||||||
static struct lsxpack_header *
|
static struct lsxpack_header *
|
||||||
hset_prepare_decode (void *hset_p, struct lsxpack_header *xhdr,
|
hset_prepare_decode (void *hset_p, struct lsxpack_header *xhdr,
|
||||||
size_t extra_space)
|
size_t req_space)
|
||||||
{
|
{
|
||||||
struct hset *const hset = hset_p;
|
struct hset *const hset = hset_p;
|
||||||
struct hset_elem *el;
|
struct hset_elem *el;
|
||||||
size_t min_space;
|
|
||||||
|
|
||||||
if (0 == extra_space)
|
if (0 == req_space)
|
||||||
min_space = 0x100;
|
req_space = 0x100;
|
||||||
else
|
|
||||||
min_space = extra_space;
|
|
||||||
|
|
||||||
if (xhdr)
|
if (req_space > LSXPACK_MAX_STRLEN)
|
||||||
min_space += xhdr->val_len;
|
|
||||||
|
|
||||||
if (min_space > LSXPACK_MAX_STRLEN)
|
|
||||||
{
|
{
|
||||||
LSQ_WARN("requested space for header is too large: %zd bytes",
|
LSQ_WARN("requested space for header is too large: %zd bytes",
|
||||||
min_space);
|
req_space);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,20 +1030,27 @@ hset_prepare_decode (void *hset_p, struct lsxpack_header *xhdr,
|
||||||
xhdr = &el->xhdr;
|
xhdr = &el->xhdr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
el = (struct hset_elem *) ((char *) xhdr
|
el = (struct hset_elem *) ((char *) xhdr
|
||||||
- offsetof(struct hset_elem, xhdr));
|
- offsetof(struct hset_elem, xhdr));
|
||||||
|
if (req_space <= el->nalloc)
|
||||||
|
{
|
||||||
|
LSQ_ERROR("requested space is smaller than already allocated");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (min_space > el->nalloc)
|
if (req_space > el->nalloc)
|
||||||
{
|
{
|
||||||
free(el->buf);
|
free(el->buf);
|
||||||
el->nalloc = 0;
|
el->nalloc = 0;
|
||||||
el->buf = malloc(min_space);
|
el->buf = malloc(req_space);
|
||||||
if (!el->buf)
|
if (!el->buf)
|
||||||
{
|
{
|
||||||
LSQ_DEBUG("cannot allocate %zd bytes", min_space);
|
LSQ_DEBUG("cannot allocate %zd bytes", req_space);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
el->nalloc = min_space;
|
el->nalloc = req_space;
|
||||||
}
|
}
|
||||||
|
|
||||||
lsxpack_header_prepare_decode(&el->xhdr, el->buf, 0, el->nalloc);
|
lsxpack_header_prepare_decode(&el->xhdr, el->buf, 0, el->nalloc);
|
||||||
|
|
|
@ -1186,7 +1186,7 @@ interop_server_hset_create (void *hsi_ctx, int is_push_promise)
|
||||||
|
|
||||||
static struct lsxpack_header *
|
static struct lsxpack_header *
|
||||||
interop_server_hset_prepare_decode (void *hset_p, struct lsxpack_header *xhdr,
|
interop_server_hset_prepare_decode (void *hset_p, struct lsxpack_header *xhdr,
|
||||||
size_t extra_space)
|
size_t req_space)
|
||||||
{
|
{
|
||||||
struct req *req = hset_p;
|
struct req *req = hset_p;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue