aboutsummaryrefslogtreecommitdiffstats
path: root/libexfat/cluster.c
diff options
context:
space:
mode:
authorrelan <relan@users.noreply.github.com>2010-04-20 19:05:18 +0000
committerrelan <relan@users.noreply.github.com>2015-08-24 08:26:12 +0300
commit4e6929313a2b2640369d646ff61a08ee43324d59 (patch)
tree293111131f259c5dd1f5e671b46b9f22cfff55e3 /libexfat/cluster.c
parent95443dc7f52685ad0918ab5065d6d304316c1984 (diff)
downloadandroid_external_exfat-4e6929313a2b2640369d646ff61a08ee43324d59.tar.gz
android_external_exfat-4e6929313a2b2640369d646ff61a08ee43324d59.tar.bz2
android_external_exfat-4e6929313a2b2640369d646ff61a08ee43324d59.zip
Fix integer overflow in block number calculation code.
Diffstat (limited to 'libexfat/cluster.c')
-rw-r--r--libexfat/cluster.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libexfat/cluster.c b/libexfat/cluster.c
index b53c31f..adebf30 100644
--- a/libexfat/cluster.c
+++ b/libexfat/cluster.c
@@ -29,12 +29,12 @@
/*
* Cluster to block.
*/
-static uint32_t c2b(const struct exfat* ef, cluster_t cluster)
+static off_t c2b(const struct exfat* ef, cluster_t cluster)
{
if (cluster < EXFAT_FIRST_DATA_CLUSTER)
exfat_bug("invalid cluster number %u", cluster);
return le32_to_cpu(ef->sb->cluster_block_start) +
- ((cluster - EXFAT_FIRST_DATA_CLUSTER) << ef->sb->bpc_bits);
+ ((off_t) (cluster - EXFAT_FIRST_DATA_CLUSTER) << ef->sb->bpc_bits);
}
/*
@@ -42,7 +42,7 @@ static uint32_t c2b(const struct exfat* ef, cluster_t cluster)
*/
off_t exfat_c2o(const struct exfat* ef, cluster_t cluster)
{
- return (off_t) c2b(ef, cluster) << ef->sb->block_bits;
+ return c2b(ef, cluster) << ef->sb->block_bits;
}
/*