Open lnussbaum opened 1 month ago
In previous versions of curl, the read callback was sent a buffer of 65KB. Curl 8.7.1 now appears to use a buffer size equal to the object being PUT.
This in turn exposes a possible bug in https://github.com/taf2/curb/blob/13144ec5d50ffea0460298cc5de8a0b33db78d22/ext/curb_easy.c#L51
The remaining < read_bytes
section works with the previously large buffer whereas the section marked // they're equal
for some reason decrements the read_bytes
value, causing the byte mismatch error in curl.
It's unclear why this behavior exists; changing remaining < read_bytes
to remaining <= read_bytes
is likely a sufficient fix for this issue.
git bisect
for curl.git shows the following change brings about this error:
https://github.com/curl/curl/commit/9369c30cd87c041cf983bcdfabd1570980abbaf6
(as the above debian bug says)
I have not read APIs of curl, and have not read the above change in detail, however reading the comment of the above commit:
test547, test555, test1620: fix the length check in the lib code to
only fail for reads *smaller* than expected. This was a bug in the
test code that never triggered in the old implementation.
and the actual code change, such as https://github.com/curl/curl/commit/9369c30cd87c041cf983bcdfabd1570980abbaf6#diff-bfeebefe5ca654a47ef7409092bf938d0002810757743093dcabc5fb301ad9feR50
seems to be suggesting that curb side code should be changed as:
diff --git a/ext/curb_easy.c b/ext/curb_easy.c
index 9054be6..74fa0e6 100644
--- a/ext/curb_easy.c
+++ b/ext/curb_easy.c
@@ -79,7 +79,7 @@ static size_t read_data_handler(void *ptr,
remaining = len - rbcu->offset;
str_ptr = RSTRING_PTR(str);
- if( remaining < read_bytes ) {
+ if( remaining <= read_bytes ) {
if( remaining > 0 ) {
memcpy(ptr, str_ptr+rbcu->offset, remaining);
read_bytes = remaining;
, as already mentioned above https://github.com/taf2/curb/blob/13144ec5d50ffea0460298cc5de8a0b33db78d22/ext/curb_easy.c#L82 And actually the above curb side change works with curl 8.6.0, 8.7.0, 8.7.1 and 8.8.0 . Would you look at this?
this is from the Debian package build, but it doesn't look specific to Debian:
The corresponding Debian bug is https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1069258
In the Debian bug, someone points to https://curl.se/mail/lib-2024-03/0054.html , which might indicate that this is a bug in curb, not in curl.
It works fine with curl 8.6.0.