]> source.dussan.org Git - jackcess.git/commitdiff
make sure database file fits expected criteria
authorJames Ahlborn <jtahlborn@yahoo.com>
Mon, 10 Mar 2008 15:31:02 +0000 (15:31 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Mon, 10 Mar 2008 15:31:02 +0000 (15:31 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@261 f203690c-595d-4dc9-a70b-905162fa7fd2

src/java/com/healthmarketscience/jackcess/PageChannel.java

index 5a94c3990c66cc950cdc43ace0646509c7e136a4..4aaa08b6e4f0441d630110cd2b9ee59df81c504f 100644 (file)
@@ -166,6 +166,12 @@ public class PageChannel implements Channel, Flushable {
       throw new IOException("Database is at maximum size " +
                             getFormat().MAX_DATABASE_SIZE);
     }
+    if((size % getFormat().PAGE_SIZE) != 0L) {
+      throw new IOException("Database corrupted, file size " + size +
+                            " is not multiple of page size " +
+                            getFormat().PAGE_SIZE);
+    }
+    
     page.rewind();
     // push the buffer to the end of the page, so that a full page's worth of
     // data is written regardless of the incoming buffer size (we use a tiny