aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2022-02-03 11:48:55 -0800
committerDave Barach <openvpp@barachs.net>2022-02-03 20:43:00 +0000
commite38babcdf9d735d15a90d91f225d115bf9e97433 (patch)
tree8410f393c65f0c165483cde66c73a9631d8d6406
parentf840880c2fd8fbd6acfa79948224aafe6e4a62d1 (diff)
http: honor max seg len in ptr buffer
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I58ecd933f36c6622f4c6b373d2d94a48f9fc9eae
-rw-r--r--src/plugins/http/http_buffer.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/http/http_buffer.c b/src/plugins/http/http_buffer.c
index 5b4f5fc0300..0b031693682 100644
--- a/src/plugins/http/http_buffer.c
+++ b/src/plugins/http/http_buffer.c
@@ -158,6 +158,7 @@ buf_ptr_get_segs (http_buffer_t *hb, u32 max_len, u32 *n_segs)
http_buffer_ptr_t *bf = (http_buffer_ptr_t *) &hb->data;
*n_segs = 1;
+ bf->segs[1].len = clib_min (bf->segs[0].len, max_len);
return &bf->segs[1];
}
@@ -167,12 +168,14 @@ buf_ptr_drain (http_buffer_t *hb, u32 len)
{
http_buffer_ptr_t *bf = (http_buffer_ptr_t *) &hb->data;
+ ASSERT (bf->segs[0].len >= len);
+
bf->segs[1].data += len;
- bf->segs[1].len -= len;
+ bf->segs[0].len -= len;
HTTP_DBG (1, "drained %u left %u", len, bf->segs[1].len);
- if (!bf->segs[1].len)
+ if (!bf->segs[0].len)
{
svm_fifo_dequeue_drop (bf->f, sizeof (uword));
return sizeof (uword);
@@ -186,8 +189,7 @@ buf_ptr_is_drained (http_buffer_t *hb)
{
http_buffer_ptr_t *bf = (http_buffer_ptr_t *) &hb->data;
- ASSERT (bf->segs[1].len <= bf->segs[0].len);
- return (bf->segs[1].len == 0);
+ return (bf->segs[0].len == 0);
}
const static http_buffer_vft_t buf_ptr_vft = {