summaryrefslogtreecommitdiffstats
path: root/Source/cmFileCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-03-17 15:05:34 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-17 15:05:34 (GMT)
commit413282c0cfb0bafc6ab325c6d4798e4765e021fa (patch)
tree67fbc2366fd549798a9e4d64284b01532e9c0b31 /Source/cmFileCommand.cxx
parentfb4aff058d2595078300b682dc477f0ccba6d31b (diff)
downloadCMake-413282c0cfb0bafc6ab325c6d4798e4765e021fa.zip
CMake-413282c0cfb0bafc6ab325c6d4798e4765e021fa.tar.gz
CMake-413282c0cfb0bafc6ab325c6d4798e4765e021fa.tar.bz2
file: Avoid runaway DOWNLOAD/UPLOAD progress reports (#14807)
Curl makes progress callbacks frequently but we round to the nearest percent and report only when that changes so that we make at most 101 progress reports. However, when unexpected data beyond the total are transferred the progress can get beyond 100% and lead to unlimited reports. Avoid this case by capping the reported progress to 100%.
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r--Source/cmFileCommand.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 9fabdc7..5bfb664 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2539,6 +2539,11 @@ namespace {
if (total > 0.0)
{
this->CurrentPercentage = static_cast<int>(value/total*100.0 + 0.5);
+ if(this->CurrentPercentage > 100)
+ {
+ // Avoid extra progress reports for unexpected data beyond total.
+ this->CurrentPercentage = 100;
+ }
}
bool updated = (OldPercentage != this->CurrentPercentage);