From 871fb7991313a02e36f50dfe8661dc40cb87cea5 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Sat, 17 Dec 2016 21:02:38 +1100 Subject: [PATCH] Check for shape table --- src/com/bytezone/diskbrowser/applefile/ShapeTable.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/com/bytezone/diskbrowser/applefile/ShapeTable.java b/src/com/bytezone/diskbrowser/applefile/ShapeTable.java index c5ca385..d7d533d 100755 --- a/src/com/bytezone/diskbrowser/applefile/ShapeTable.java +++ b/src/com/bytezone/diskbrowser/applefile/ShapeTable.java @@ -134,6 +134,11 @@ public class ShapeTable extends AbstractFile if (totalShapes == 0) return false; + // this prevents large files that start with a very small value + // System.out.printf ("Average shape length: %d%n", buffer.length / totalShapes); + if (totalShapes * 500 < buffer.length) + return false; + for (int i = 0; i < totalShapes; i++) { // check index table entry is inside the file @@ -149,6 +154,7 @@ public class ShapeTable extends AbstractFile // check offset is unique if (offsets.contains (offset)) return false; + offsets.add (offset); }