MEDIUM: buffers: fix unsafe use of buffer_ignore at some places
buffer_ignore may only be used when the output of a buffer is empty,
but it's not granted it is always the case when sending HTTP error
responses. Better use buffer_cut_tail() instead, and use buffer_ignore
only on non-wrapping data.
diff --git a/include/proto/buffers.h b/include/proto/buffers.h
index a95e5a1..f35da64 100644
--- a/include/proto/buffers.h
+++ b/include/proto/buffers.h
@@ -343,17 +343,16 @@
buf->flags |= BF_FULL;
}
-/* Cut the <n> next unsent bytes of the buffer. The caller must ensure that <n>
- * is smaller than the actual buffer's length. This is mainly used to remove
- * empty lines at the beginning of a request or a response.
+/* Cut the first <n> pending bytes in a contiguous buffer. It is illegal to
+ * call this function with remaining data waiting to be sent (o > 0). The
+ * caller must ensure that <n> is smaller than the actual buffer's length.
+ * This is mainly used to remove empty lines at the beginning of a request
+ * or a response.
*/
static inline void buffer_ignore(struct buffer *buf, int n)
{
buf->i -= n;
- buf->p = buffer_wrap_add(buf, buf->p + n);
- buf->flags &= ~BF_FULL;
- if (buffer_len(buf) >= buffer_max_len(buf))
- buf->flags |= BF_FULL;
+ buf->p += n;
}
/* marks the buffer as "shutdown" ASAP for reads */