exfat: avoid overflow in Volume::ClusterToBlock().
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2010, Axel Dörfler, [email protected].
|
* Copyright 2008-2010, Axel Dörfler, [email protected].
|
||||||
* Copyright 2011, Jérôme Duval, [email protected].
|
* Copyright 2011-2019, Jérôme Duval, [email protected].
|
||||||
* Copyright 2014 Haiku, Inc. All rights reserved.
|
* Copyright 2014 Haiku, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@@ -416,9 +416,10 @@ Volume::LoadSuperBlock()
|
|||||||
status_t
|
status_t
|
||||||
Volume::ClusterToBlock(cluster_t cluster, fsblock_t &block)
|
Volume::ClusterToBlock(cluster_t cluster, fsblock_t &block)
|
||||||
{
|
{
|
||||||
if (cluster < 2)
|
if (cluster < EXFAT_FIRST_DATA_CLUSTER)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
block = ((cluster - 2) << SuperBlock().BlocksPerClusterShift())
|
block = ((fsblock_t)(cluster - EXFAT_FIRST_DATA_CLUSTER)
|
||||||
|
<< SuperBlock().BlocksPerClusterShift())
|
||||||
+ SuperBlock().FirstDataBlock();
|
+ SuperBlock().FirstDataBlock();
|
||||||
TRACE("Volume::ClusterToBlock() cluster %" B_PRIu32 " %u %" B_PRIu32 ": %"
|
TRACE("Volume::ClusterToBlock() cluster %" B_PRIu32 " %u %" B_PRIu32 ": %"
|
||||||
B_PRIu64 ", %" B_PRIu32 "\n", cluster,
|
B_PRIu64 ", %" B_PRIu32 "\n", cluster,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2011, Jérôme Duval, [email protected].
|
* Copyright 2011-2019, Jérôme Duval, [email protected].
|
||||||
* Copyright 2014 Haiku, Inc. All Rights reserved.
|
* Copyright 2014 Haiku, Inc. All Rights reserved.
|
||||||
*
|
*
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
@@ -26,6 +26,7 @@ typedef uint32 cluster_t;
|
|||||||
|
|
||||||
|
|
||||||
#define EXFAT_SUPER_BLOCK_OFFSET 0x0
|
#define EXFAT_SUPER_BLOCK_OFFSET 0x0
|
||||||
|
#define EXFAT_FIRST_DATA_CLUSTER 2
|
||||||
|
|
||||||
|
|
||||||
struct exfat_super_block {
|
struct exfat_super_block {
|
||||||
|
|||||||
Reference in New Issue
Block a user