From 87c498fa415d1e68fd27c8bcf86e694094c609ae Mon Sep 17 00:00:00 2001 From: Brian Pellin Date: Sun, 25 Apr 2010 14:50:51 -0500 Subject: [PATCH] Add warning if number of key encryption round is more than I currently handle. --- src/com/keepassdroid/database/PwDbHeaderV3.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/keepassdroid/database/PwDbHeaderV3.java b/src/com/keepassdroid/database/PwDbHeaderV3.java index 1a851cb50..7c445eb9b 100644 --- a/src/com/keepassdroid/database/PwDbHeaderV3.java +++ b/src/com/keepassdroid/database/PwDbHeaderV3.java @@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA package com.keepassdroid.database; +import java.io.IOException; + import com.keepassdroid.utils.Types; public class PwDbHeaderV3 extends PwDbHeader { @@ -67,8 +69,9 @@ public class PwDbHeaderV3 extends PwDbHeader { /** * Parse given buf, as read from file. * @param buf + * @throws IOException */ - public void loadFromFile( byte buf[], int offset ) { + public void loadFromFile( byte buf[], int offset ) throws IOException { signature1 = Types.readInt( buf, offset + 0 ); signature2 = Types.readInt( buf, offset + 4 ); flags = Types.readInt( buf, offset + 8 ); @@ -84,6 +87,10 @@ public class PwDbHeaderV3 extends PwDbHeader { System.arraycopy( buf, offset + 88, mTransformSeed, 0, 32 ); numKeyEncRounds = Types.readInt( buf, offset + 120 ); + if ( numKeyEncRounds < 0 ) { + // TODO: Really treat this like an unsigned integer + throw new IOException("Does not support more than " + Integer.MAX_VALUE + " rounds."); + } } public PwDbHeaderV3() {