mirror of
https://github.com/rclone/rclone.git
synced 2025-11-23 21:44:49 +02:00
about: fix potential overflow of about in various backends
Before this fix it was possible for an about call in various backends to exceed an int64 and wrap. This patch causes it to clip to the max int64 value instead.
This commit is contained in:
@@ -494,11 +494,11 @@ func (f *Fs) About(ctx context.Context) (_ *fs.Usage, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bs := int64(stat.BlockSize())
|
||||
bs := stat.BlockSize()
|
||||
usage := &fs.Usage{
|
||||
Total: fs.NewUsageValue(bs * int64(stat.TotalBlockCount())),
|
||||
Used: fs.NewUsageValue(bs * int64(stat.TotalBlockCount()-stat.FreeBlockCount())),
|
||||
Free: fs.NewUsageValue(bs * int64(stat.AvailableBlockCount())),
|
||||
Total: fs.NewUsageValue(bs * stat.TotalBlockCount()),
|
||||
Used: fs.NewUsageValue(bs * (stat.TotalBlockCount() - stat.FreeBlockCount())),
|
||||
Free: fs.NewUsageValue(bs * stat.AvailableBlockCount()),
|
||||
}
|
||||
return usage, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user