diff --git a/include/common/buffer.h b/include/common/buffer.h index 0c8eeb019..8638bd684 100644 --- a/include/common/buffer.h +++ b/include/common/buffer.h @@ -105,16 +105,6 @@ static inline void bo_del(struct buffer *b, unsigned int del) b->o -= del; } -/* Returns the amount of output data that can contiguously be read at once */ -static inline int bo_contig_data(const struct buffer *b) -{ - char *beg = b->p - b->o; - - if (beg < b->data) - return b->data - beg; - return b->o; -} - /* Return the amount of bytes that can be written into the input area at once * including reserved space which may be overwritten (this is the caller * responsibility to know if the reserved space is protected or not). diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 0ccf23b12..99b18cc4f 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -720,7 +720,10 @@ http_compression_buffer_end(struct comp_state *st, struct stream *s, /* Copy previous data from ib->o into ob->o */ if (ib->o > 0) { - left = bo_contig_data(ib); + left = b_contig_data(ib, 0); + if (left > ib->o) + left = ib->o; + memcpy(ob->p - ob->o, b_head(ib), left); if (ib->o - left) /* second part of the buffer */ memcpy(ob->p - ob->o + left, ib->data, ib->o - left); diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 56d2eed7f..e694c8721 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -5526,7 +5526,9 @@ static int ssl_sock_from_buf(struct connection *conn, struct buffer *buf, int fl size_t written_data; #endif - try = bo_contig_data(buf); + try = b_contig_data(buf, 0); + if (try > buf->o) + try = buf->o; if (!(flags & CO_SFL_STREAMER) && !(conn->xprt_st & SSL_SOCK_SEND_UNLIMITED) &&