hrev52917 adds 1 changeset to branch 'master'
old head: a54fc27a11ff857643d4b0dacaf641cc9ceb9ef3
new head: 14263044aac31fb9b570850708a3c29a4f44f95d
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=14263044aac3+%5Ea54fc27a11ff
----------------------------------------------------------------------------
14263044aac3: exfat: avoid overflow in Volume::ClusterToBlock().
[ Jérôme Duval <jerome.duval@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev52917
Commit: 14263044aac31fb9b570850708a3c29a4f44f95d
URL: https://git.haiku-os.org/haiku/commit/?id=14263044aac3
Author: Jérôme Duval <jerome.duval@xxxxxxxxx>
Date: Fri Feb 22 17:31:09 2019 UTC
----------------------------------------------------------------------------
2 files changed, 6 insertions(+), 4 deletions(-)
src/add-ons/kernel/file_systems/exfat/Volume.cpp | 7 ++++---
src/add-ons/kernel/file_systems/exfat/exfat.h | 3 ++-
----------------------------------------------------------------------------
diff --git a/src/add-ons/kernel/file_systems/exfat/Volume.cpp
b/src/add-ons/kernel/file_systems/exfat/Volume.cpp
index 44f6d2e189..aa9dbbe5e3 100644
--- a/src/add-ons/kernel/file_systems/exfat/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/exfat/Volume.cpp
@@ -1,6 +1,6 @@
/*
* Copyright 2008-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
- * Copyright 2011, Jérôme Duval, korli@xxxxxxxxxxxxxxxx.
+ * Copyright 2011-2019, Jérôme Duval, jerome.duval@xxxxxxxxx.
* Copyright 2014 Haiku, Inc. All rights reserved.
*
* Distributed under the terms of the MIT License.
@@ -416,9 +416,10 @@ Volume::LoadSuperBlock()
status_t
Volume::ClusterToBlock(cluster_t cluster, fsblock_t &block)
{
- if (cluster < 2)
+ if (cluster < EXFAT_FIRST_DATA_CLUSTER)
return B_BAD_VALUE;
- block = ((cluster - 2) << SuperBlock().BlocksPerClusterShift())
+ block = ((fsblock_t)(cluster - EXFAT_FIRST_DATA_CLUSTER)
+ << SuperBlock().BlocksPerClusterShift())
+ SuperBlock().FirstDataBlock();
TRACE("Volume::ClusterToBlock() cluster %" B_PRIu32 " %u %" B_PRIu32 ":
%"
B_PRIu64 ", %" B_PRIu32 "\n", cluster,
diff --git a/src/add-ons/kernel/file_systems/exfat/exfat.h
b/src/add-ons/kernel/file_systems/exfat/exfat.h
index b08a715018..6c5ea1a13f 100644
--- a/src/add-ons/kernel/file_systems/exfat/exfat.h
+++ b/src/add-ons/kernel/file_systems/exfat/exfat.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011, Jérôme Duval, korli@xxxxxxxxxxxxxxxx.
+ * Copyright 2011-2019, Jérôme Duval, jerome.duval@xxxxxxxxx.
* Copyright 2014 Haiku, Inc. All Rights reserved.
*
* Distributed under the terms of the MIT License.
@@ -26,6 +26,7 @@ typedef uint32 cluster_t;
#define EXFAT_SUPER_BLOCK_OFFSET 0x0
+#define EXFAT_FIRST_DATA_CLUSTER 2
struct exfat_super_block {