diff --git a/CHANGELOG.md b/CHANGELOG.md index 789bfa9..46d857f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.1.1 + +- Throw KdbxInvalidFileStructure for invalid files. + ## 2.1.0 - Implement permanently removing entries and groups. diff --git a/lib/src/kdbx_header.dart b/lib/src/kdbx_header.dart index 1b3d58f..889623b 100644 --- a/lib/src/kdbx_header.dart +++ b/lib/src/kdbx_header.dart @@ -385,7 +385,7 @@ class KdbxHeader { final sig1 = reader.readUint32(); final sig2 = reader.readUint32(); if (!(sig1 == Consts.FileMagic && sig2 == Consts.Sig2Kdbx)) { - throw UnsupportedError( + throw KdbxInvalidFileStructure( 'Unsupported file structure. ${ByteUtils.toHex(sig1)}, ' '${ByteUtils.toHex(sig2)}'); } @@ -583,6 +583,17 @@ class KdbxUnsupportedException implements KdbxException { } } +class KdbxInvalidFileStructure implements KdbxException { + KdbxInvalidFileStructure(this.message); + + final String message; + + @override + String toString() { + return 'KdbxInvalidFileStructure{$message}'; + } +} + class HashedBlockReader { static const BLOCK_SIZE = 1024 * 1024; static const HASH_SIZE = 32;