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%.
This commit is contained in:
Brad King 2014-03-17 11:05:34 -04:00
parent fb4aff058d
commit 413282c0cf
1 changed files with 5 additions and 0 deletions

View File

@ -2539,6 +2539,11 @@ namespace {
if (total > 0.0) if (total > 0.0)
{ {
this->CurrentPercentage = static_cast<int>(value/total*100.0 + 0.5); 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); bool updated = (OldPercentage != this->CurrentPercentage);