Throw exception if bad header

This commit is contained in:
J-Jamet
2021-03-24 11:20:30 +01:00
parent edf3525a3f
commit d28a59a2fe

View File

@@ -253,10 +253,15 @@ class DatabaseInputKDBX(cacheDirectory: File,
if (size < 0) throw IOException("Corrupted file") if (size < 0) throw IOException("Corrupted file")
var data = ByteArray(0) var data = ByteArray(0)
if (size > 0) { try {
if (fieldId != DatabaseHeaderKDBX.PwDbInnerHeaderV4Fields.Binary) { if (size > 0) {
data = dataInputStream.readBytes(size) if (fieldId != DatabaseHeaderKDBX.PwDbInnerHeaderV4Fields.Binary) {
data = dataInputStream.readBytes(size)
}
} }
} catch (e: Exception) {
// OOM only if corrupted file
throw IOException("Corrupted file")
} }
var result = true var result = true