bufq: unwrite fix

`Curl_bufq_unwrite()` used the head instead of the tail chunk to shrink
the bufq's content. Fix this and add test case that checks correct
behaviour.

Amended test 2601 accordingly.

Reported-by: Chris Stubbs
Closes #15136
This commit is contained in:
Stefan Eissing 2024-10-03 10:15:07 +02:00 committed by Daniel Stenberg
parent 08d13c0e46
commit 2400a6c6b2
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 48 additions and 1 deletions

View file

@ -76,6 +76,17 @@ void Curl_bufq_skip(struct bufq *q, size_t amount);
This removes `amount` number of bytes from the `bufq`.
## unwrite
It is possible to undo writes by calling:
```
CURLcode Curl_bufq_unwrite(struct bufq *q, size_t len);
```
This will remove `len` bytes from the end of the bufq again. When removing
more bytes than are present, CURLE_AGAIN is returned and the bufq will be
empty.
## lifetime