Revision: 5812
http://jnode.svn.sourceforge.net/jnode/?rev=5812&view=rev
Author: lsantha
Date: 2011-06-05 08:59:23 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
Applied patch by Daniel Noll:
"Infinite loop reading NTFS indexes if disk exhibits a certain kind of corruption.
I found a situation where an IndexEntryIterator's offset will not be incremented each time next() is called, if the size of an entry is zero (presumably due to corruption.)
Attached patch makes this condition fail faster with an ISE."
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntryIterator.java
Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntryIterator.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntryIterator.java 2011-04-28 18:43:05 UTC (rev 5811)
+++ trunk/fs/src/fs/org/jnode/fs/ntfs/IndexEntryIterator.java 2011-06-05 08:59:23 UTC (rev 5812)
@@ -64,7 +64,16 @@
throw new NoSuchElementException();
} else {
final IndexEntry result = nextEntry;
- final int size = nextEntry.getSize();
+ final int size = nextEntry.getSize();
+
+ // Prevents an infinite loop. Seen on images where the size of the index entry has been zeroed out.
+ if (size <= 0) {
+ throw new IllegalStateException(String.format(
+ "Index entry size is 0, filesystem is corrupt. Parent directory: '%s', reference number '%d'",
+ nextEntry.getParentFileRecord().getFileName(),
+ nextEntry.getParentFileRecord().getReferenceNumber()));
+ }
+
offset += size;
// Now read the next next entry
readNext();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|