From 413282c0cfb0bafc6ab325c6d4798e4765e021fa Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 17 Mar 2014 11:05:34 -0400 Subject: 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%. --- Source/cmFileCommand.cxx | 5 +++++ 1 file changed, 5 insertions(+) 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(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); -- cgit v0.12