diff --git a/backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch b/backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch new file mode 100644 index 0000000000000000000000000000000000000000..cd27057225334a31894814e29ccdb90f1dbdddfc --- /dev/null +++ b/backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch @@ -0,0 +1,61 @@ +From 5f4aaf8b66ef04208c1c2121d4b780c792303f32 Mon Sep 17 00:00:00 2001 +From: Daniel Stenberg +Date: Tue, 30 Apr 2024 11:07:28 +0200 +Subject: [PATCH] tool_cb_rea: limit rate unpause for -T . uploads +Reference:https://github.com/curl/curl/pull/13506 +--- + src/tool_cb_rea.c | 31 +++++++++++++++++++++++++++++-- + 1 file changed, 29 insertions(+), 2 deletions(-) + +diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c +index 507373d..67241be 100644 +--- a/src/tool_cb_rea.c ++++ b/src/tool_cb_rea.c +@@ -28,6 +28,7 @@ + #include "tool_cfgable.h" + #include "tool_cb_rea.h" + #include "tool_operate.h" ++#include "tool_sleep.h" + + #include "memdebug.h" /* keep this as LAST include */ + +@@ -71,8 +72,34 @@ int tool_readbusy_cb(void *clientp, + (void)ulnow; /* unused */ + + if(config->readbusy) { +- config->readbusy = FALSE; +- curl_easy_pause(per->curl, CURLPAUSE_CONT); ++ /* lame code to keep the rate down because the input might not deliver ++ anything, get paused again and come back here immediately */ ++ static long rate = 500; ++ static struct timeval prev; ++ static curl_off_t ulprev; ++ ++ if(ulprev == ulnow) { ++ /* it did not upload anything since last call */ ++ if(prev.tv_sec) { ++ struct timeval now = tvnow(); ++ /* get a rolling average rate */ ++ /* rate = rate - rate/4 + tvdiff(now, prev)/4; */ ++ rate -= rate/4 - tvdiff(now, prev)/4; ++ prev = now; ++ } ++ } ++ else { ++ rate = 50; ++ ulprev = ulnow; ++ } ++ if(rate >= 50) { ++ /* keeps the looping down to 20 times per second in the crazy case */ ++ config->readbusy = FALSE; ++ curl_easy_pause(per->curl, CURLPAUSE_CONT); ++ } ++ else ++ /* sleep half a period */ ++ tool_go_sleep(25); + } + + return per->noprogress? 0 : CURL_PROGRESSFUNC_CONTINUE; +-- +2.27.0 + diff --git a/curl.spec b/curl.spec index 4453d1480811d2be2d0afae6009cf0b5aeadefde..22394c1bfc24db27ca08250185afd21867ef80e7 100644 --- a/curl.spec +++ b/curl.spec @@ -6,7 +6,7 @@ Name: curl Version: 7.79.1 -Release: 28 +Release: 29 Summary: Curl is used in command lines or scripts to transfer data License: MIT URL: https://curl.haxx.se/ @@ -97,6 +97,8 @@ Patch83: backport-urlapi-make-sure-zoneid-is-also-duplicated-in-curl_u.pa Patch84: backport-transfer-also-stop-the-sending-on-closed-connection.patch Patch85: backport-openssl-avoid-BN_num_bits-NULL-pointer-derefs.patch Patch86: backport-CVE-2024-2398.patch +Patch87: backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch +#https://github.com/curl/curl/pull/13506 BuildRequires: automake brotli-devel coreutils gcc groff krb5-devel BuildRequires: libidn2-devel libnghttp2-devel libpsl-devel @@ -265,6 +267,12 @@ rm -rf ${RPM_BUILD_ROOT}%{_libdir}/libcurl.la %{_mandir}/man3/* %changelog +* Thu May 23 2024 baiguo - 7.79.1-29 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:tool_cb_rea: limit rate unpause for -T . uploads + * Fri Mar 29 2024 zhouyihang - 7.79.1-28 - Type:CVE - CVE:CVE-2024-2398