[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Synaptic-devel] Percentage of file fetched shows incorrectly on lar
From: |
Michael Vogt |
Subject: |
Re: [Synaptic-devel] Percentage of file fetched shows incorrectly on large files |
Date: |
Wed, 6 Aug 2003 12:12:09 +0200 |
User-agent: |
Mutt/1.5.4i |
On Tue, Aug 05, 2003 at 09:19:51PM -0700, David Wilson wrote:
> 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.
Thanks for finding this bug and providing all this usefull
information about it.
[..]
> The following logic should take care of the problem:
>
> static unsigned int PROGRESS_PERCENT_OVERFLOW = 42949672;
> if (I->TotalSize >= PROGRESS_PERCENT_OVERFLOW)
If we do it this way, we probably should use :
+ if (I->TotalSize >= ULONG_MAX/100)
as CurrentSize and TotalSize are defined as usigned long. ULONG_MAX
comes from limits.h and is usefull as it will take care for 64bit
plattforms.
> [code skiped]
I'll probably fix the problem like this:
updateStatus(*I->CurrentItem,
long(double(I->CurrentSize*100.0)/double(I->TotalSize)));
because it will save us the additional if() statement.
Again, thanks a lot for finding this bug and your help fixing it :)
thanks,
Michael