[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libvir] PATCH: 11/16: directory/fs/netfs backend



On Fri, Feb 15, 2008 at 09:37:53PM +0100, Jim Meyering wrote:
> It'd be good to pull the duplicate capacity update out of the
> if- and else- blocks.
> 
>     def->capacity *= ...
> 
> Also, just in case the file data is bogus enough to make the resulting
> product overflow, you can detect that with e.g.,
> 
>       if (def->capacity > ULLONG_MAX / fileTypeInfo[i].sizeMultiplier)
>           continue;
>       def->capacity *= fileTypeInfo[i].sizeMultiplier;
> 
> If the test fails, I'd be tempted to give a diagnostic
> about the corrupt "size" data.

Originally I thought there would be no overflow risk, since the only file
types with a sizeMultiplier were those with a 4 byte size field. But I see
now that actually VMDK 4 format has an 8 byte size and a 512 multiplier.
So I'll add the sanity check...

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]