[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Synaptic-devel] Percentage of file fetched shows incorrectly on large f
From: |
David Wilson |
Subject: |
[Synaptic-devel] Percentage of file fetched shows incorrectly on large files |
Date: |
05 Aug 2003 21:19:51 -0700 |
There is an unsigned integer overflow that occurs when calculating the
percentage downloaded when fetching large files(>40MB). The actual
overflow results when the amount of file downloaded is >= (2^32)/100.
The problem is in the calculation of the second argument in the call to
updateStatus found in gtk/rgfetchprogess.cc:
if (I->TotalSize > 0)
updateStatus(*I->CurrentItem, I->CurrentSize*100 / I->TotalSize);
else
updateStatus(*I->CurrentItem, 100);
}
The following logic should take care of the problem:
static unsigned int PROGRESS_PERCENT_OVERFLOW = 42949672;
if (I->TotalSize >= PROGRESS_PERCENT_OVERFLOW)
{
// a couple of extra integer divisions should prevent the overflow
updateStatus(*I->CurrentItem,
(I->CurrentSize/100)*100 / (I->TotalSize/100));
}
else if (I->TotalSize > 0)
updateStatus(*I->CurrentItem, I->CurrentSize*100 / I->TotalSize);
else
updateStatus(*I->CurrentItem, 100);
}
--
David A. Wilson
address@hidden
Home: 206-325-1757
Cell: 206-713-1369
- [Synaptic-devel] Percentage of file fetched shows incorrectly on large files,
David Wilson <=