OSDN Git Service

Android: print log messages to logcat.
[android-x86/external-exfat.git] / libexfat / mount.c
index 130b5ef..3b18b12 100644 (file)
@@ -3,7 +3,7 @@
        exFAT file system implementation library.
 
        Free exFAT implementation.
-       Copyright (C) 2010-2017  Andrew Nayenko
+       Copyright (C) 2010-2018  Andrew Nayenko
 
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
@@ -276,11 +276,21 @@ int exfat_mount(struct exfat* ef, const char* spec, const char* options)
        {
                /* this can cause I/O errors later but we don't fail mounting to let
                   user rescue data */
-               exfat_warn("file system is larger than underlying device: "
-                               "%"PRIu64" > %"PRIu64,
-                               le64_to_cpu(ef->sb->sector_count) * SECTOR_SIZE(*ef->sb),
+               exfat_warn("file system in sectors is larger than device: "
+                               "%"PRIu64" * %d > %"PRIu64,
+                               le64_to_cpu(ef->sb->sector_count), SECTOR_SIZE(*ef->sb),
                                exfat_get_size(ef->dev));
        }
+       if ((off_t) le32_to_cpu(ef->sb->cluster_count) * CLUSTER_SIZE(*ef->sb) >
+                       exfat_get_size(ef->dev))
+       {
+               exfat_error("file system in clusters is larger than device: "
+                               "%u * %d > %"PRIu64,
+                               le32_to_cpu(ef->sb->cluster_count), CLUSTER_SIZE(*ef->sb),
+                               exfat_get_size(ef->dev));
+               exfat_free(ef);
+               return -EIO;
+       }
 
        ef->root = malloc(sizeof(struct exfat_node));
        if (ef->root == NULL)