# HG changeset patch # User Olaf Wintermann # Date 1670081468 -3600 # Node ID 02b003f7560cb23a0b916de4cd0fc86f8147fe27 # Parent 45d1b02fa80bbb92851785de0c1ec8e911663188 use separate buffer for chunked transfer encoding, not inbuf diff -r 45d1b02fa80b -r 02b003f7560c src/server/daemon/httprequest.c --- a/src/server/daemon/httprequest.c Sat Dec 03 13:54:53 2022 +0100 +++ b/src/server/daemon/httprequest.c Sat Dec 03 16:31:08 2022 +0100 @@ -302,7 +302,6 @@ absPath.length, rq->rq.reqpb); } else { - // TODO: log error log_ereport( LOG_WARN, "uri unescape failed: {%.*s}", @@ -421,16 +420,28 @@ if(transfer_encoding) { if(!strcmp(transfer_encoding, "chunked")) { netbuf *nb = sn->netbuf; - sn->buffer = (char*)nb->inbuf; + sn->buffer = pool_malloc(pool, nb->maxsize); + if(!sn->buffer) { + pool_destroy(pool); + // TODO: error 500 + return 1; + } + if(nb->cursize - nb->pos > 0) { + memcpy(sn->buffer, nb->inbuf, nb->cursize); + } + sn->pos = nb->pos; sn->cursize = nb->cursize; + nb->pos = 0; + nb->cursize = 0; + if(httpstream_enable_chunked_read(sn->sn.csd, sn->buffer, nb->maxsize, &sn->cursize, &sn->pos)) { pool_destroy(pool); // TODO: error 500 return 1; } - } + } // else: TODO: unknown transfer encoding error } //