Commit 23ca54d8 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Add an assert preventing buffer overflows

Make sure that the workspace can accomodate the pipelined data before
memmoving it into place.

Add a comment on an open issue in the H2 code path that could trigger
this assert.
parent 333e6da1
......@@ -196,6 +196,7 @@ HTC_RxInit(struct http_conn *htc, struct ws *ws)
if (htc->pipeline_b != NULL) {
l = htc->pipeline_e - htc->pipeline_b;
assert(l > 0);
assert(l <= ws->r - htc->rxbuf_b);
memmove(htc->rxbuf_b, htc->pipeline_b, l);
htc->rxbuf_e += l;
htc->pipeline_b = NULL;
......
......@@ -661,6 +661,9 @@ h2_new_ou_session(struct worker *wrk, struct h2_sess *h2,
h2->htc->pipeline_e = req->htc->pipeline_e;
req->htc->pipeline_b = NULL;
req->htc->pipeline_e = NULL;
/* XXX: This call may assert on buffer overflow if the pipelined
data exceeds the available space in the aws workspace. What to
do about the overflowing data is an open issue. */
HTC_RxInit(h2->htc, wrk->aws);
/* Start req thread */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment