From: Stefan Eissing Date: Thu, 25 Sep 2025 11:25:29 +0000 (+0200) Subject: transfer: avoid busy loop with tiny speed limit X-Git-Tag: rc-8_17_0-1~234 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=221b7dda3837940532b03fbc5f7c54d8a6edd266;p=thirdparty%2Fcurl.git transfer: avoid busy loop with tiny speed limit When a transfer has a speed limit less than 4, the receive loop early exits without receiving anything, causing a busy loop for that transfer. Perform that check only after the first receive has been done. Reported in Joshua's sarif data Closes #18732 --- diff --git a/lib/transfer.c b/lib/transfer.c index 1297a3e82d..62528d2275 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -283,7 +283,7 @@ static CURLcode sendrecv_dl(struct Curl_easy *data, * a quarter of the quota, break out. We want to stutter a bit * to keep in the limit, but too small receives will just cost * cpu unnecessarily. */ - if(total_received >= (data->set.max_recv_speed / 4)) + if(total_received && (total_received >= (data->set.max_recv_speed / 4))) break; if(data->set.max_recv_speed < (curl_off_t)bytestoread) bytestoread = (size_t)data->set.max_recv_speed;