mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Check file size to not corrupt a database v1 if too high
This commit is contained in:
@@ -101,9 +101,14 @@ class EntryOutputKDB
|
||||
// Binary
|
||||
mOutputStream.write(BINARY_DATA_FIELD_TYPE)
|
||||
val binaryData = mEntry.binaryData
|
||||
val binaryDataLength = (binaryData?.length()?.toInt() ?: 0) // TODO if length > long show exception UInt
|
||||
val binaryDataLength = binaryData?.length() ?: 0
|
||||
val binaryDataLengthRightSize = if (binaryDataLength <= Int.MAX_VALUE) {
|
||||
binaryDataLength.toInt()
|
||||
} else {
|
||||
0 // TODO if length > UInt.maxvalue show exception
|
||||
}
|
||||
// Write data length
|
||||
mOutputStream.write(writeIntBuf(binaryDataLength))
|
||||
mOutputStream.write(writeIntBuf(binaryDataLengthRightSize))
|
||||
// Write data
|
||||
if (binaryDataLength > 0) {
|
||||
binaryData?.getInputDataStream().use { inputStream ->
|
||||
|
||||
Reference in New Issue
Block a user