[BUG] fix buffer_skip() and buffer_si_getline() to correctly handle wrap-arounds
Those two functions did not correctly deal with full buffers and/or
buffers that wrapped around. Buffer_skip() was even able to incorrectly
set buf->w further than the end of buffer if its len argument was wrong,
and buffer_si_getline() was able to incorrectly return a length larger
than the effective buffer data available.
diff --git a/include/proto/buffers.h b/include/proto/buffers.h
index ab47b4f..3a43678 100644
--- a/include/proto/buffers.h
+++ b/include/proto/buffers.h
@@ -331,13 +331,13 @@
* Advance the buffer's read pointer by <len> bytes. This is useful when data
* have been read directly from the buffer. It is illegal to call this function
* with <len> causing a wrapping at the end of the buffer. It's the caller's
- * responsibility to ensure that <len> is never larger than buffer_contig_data.
+ * responsibility to ensure that <len> is never larger than buf->send_max.
*/
static inline void buffer_skip(struct buffer *buf, int len)
{
buf->w += len;
- if (buf->w == buf->data + buf->size)
- buf->w = buf->data; /* wrap around the buffer */
+ if (buf->w >= buf->data + buf->size)
+ buf->w -= buf->size; /* wrap around the buffer */
buf->l -= len;
if (!buf->l)