Browse Source

Throw KdbxInvalidFileStructure for invalid files

pull/5/head
Herbert Poul 3 years ago
parent
commit
3570757fae
  1. 4
      CHANGELOG.md
  2. 13
      lib/src/kdbx_header.dart

4
CHANGELOG.md

@ -1,3 +1,7 @@
## 2.1.1
- Throw KdbxInvalidFileStructure for invalid files.
## 2.1.0 ## 2.1.0
- Implement permanently removing entries and groups. - Implement permanently removing entries and groups.

13
lib/src/kdbx_header.dart

@ -385,7 +385,7 @@ class KdbxHeader {
final sig1 = reader.readUint32(); final sig1 = reader.readUint32();
final sig2 = reader.readUint32(); final sig2 = reader.readUint32();
if (!(sig1 == Consts.FileMagic && sig2 == Consts.Sig2Kdbx)) { if (!(sig1 == Consts.FileMagic && sig2 == Consts.Sig2Kdbx)) {
throw UnsupportedError( throw KdbxInvalidFileStructure(
'Unsupported file structure. ${ByteUtils.toHex(sig1)}, ' 'Unsupported file structure. ${ByteUtils.toHex(sig1)}, '
'${ByteUtils.toHex(sig2)}'); '${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 { class HashedBlockReader {
static const BLOCK_SIZE = 1024 * 1024; static const BLOCK_SIZE = 1024 * 1024;
static const HASH_SIZE = 32; static const HASH_SIZE = 32;

Loading…
Cancel
Save