mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Go back to explicitly storing blank fields in the database
Works around bug in keepassx
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
* Go back to explicitly storing blank fields in the database
|
||||
(works around bug in keepassx)
|
||||
|
||||
KeePassdroid (1.9.8)
|
||||
* Fix crashes related to saving missing entries
|
||||
* Fix issues with setting wrong expiry date
|
||||
|
||||
BIN
assets/test1.kdb
BIN
assets/test1.kdb
Binary file not shown.
@@ -23,7 +23,6 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import com.keepassdroid.database.PwEntryV3;
|
||||
import com.keepassdroid.utils.EmptyUtils;
|
||||
import com.keepassdroid.utils.Types;
|
||||
|
||||
public class PwEntryOutputV3 {
|
||||
@@ -52,7 +51,7 @@ public class PwEntryOutputV3 {
|
||||
public static final byte[] ZERO_FIELD_SIZE = Types.writeInt(0);
|
||||
public static final byte[] ZERO_FIVE = {0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
public static final byte[] TEST = {0x33, 0x33, 0x33, 0x33};
|
||||
|
||||
|
||||
private OutputStream mOS;
|
||||
private PwEntryV3 mPE;
|
||||
private long outputBytes = 0;
|
||||
@@ -82,89 +81,59 @@ public class PwEntryOutputV3 {
|
||||
mOS.write(Types.writeInt(mPE.groupId));
|
||||
|
||||
// Image ID
|
||||
if (mPE.icon != null) {
|
||||
mOS.write(IMAGEID_FIELD_TYPE);
|
||||
mOS.write(LONG_FOUR);
|
||||
mOS.write(Types.writeInt(mPE.icon.iconId));
|
||||
}
|
||||
mOS.write(IMAGEID_FIELD_TYPE);
|
||||
mOS.write(LONG_FOUR);
|
||||
mOS.write(Types.writeInt(mPE.icon.iconId));
|
||||
|
||||
// Title
|
||||
//byte[] title = mPE.title.getBytes("UTF-8");
|
||||
if (!EmptyUtils.isNullOrEmpty(mPE.title)) {
|
||||
mOS.write(TITLE_FIELD_TYPE);
|
||||
int titleLen = Types.writeCString(mPE.title, mOS);
|
||||
outputBytes += titleLen;
|
||||
}
|
||||
mOS.write(TITLE_FIELD_TYPE);
|
||||
int titleLen = Types.writeCString(mPE.title, mOS);
|
||||
outputBytes += titleLen;
|
||||
|
||||
// URL
|
||||
if (!EmptyUtils.isNullOrEmpty(mPE.url)) {
|
||||
mOS.write(URL_FIELD_TYPE);
|
||||
int urlLen = Types.writeCString(mPE.url, mOS);
|
||||
outputBytes += urlLen;
|
||||
}
|
||||
mOS.write(URL_FIELD_TYPE);
|
||||
int urlLen = Types.writeCString(mPE.url, mOS);
|
||||
outputBytes += urlLen;
|
||||
|
||||
// Username
|
||||
if (!EmptyUtils.isNullOrEmpty(mPE.username)) {
|
||||
mOS.write(USERNAME_FIELD_TYPE);
|
||||
int userLen = Types.writeCString(mPE.username, mOS);
|
||||
outputBytes += userLen;
|
||||
}
|
||||
mOS.write(USERNAME_FIELD_TYPE);
|
||||
int userLen = Types.writeCString(mPE.username, mOS);
|
||||
outputBytes += userLen;
|
||||
|
||||
// Password
|
||||
byte[] password = mPE.getPasswordBytes();
|
||||
if (!EmptyUtils.isNullOrEmpty(password)) {
|
||||
mOS.write(PASSWORD_FIELD_TYPE);
|
||||
mOS.write(Types.writeInt(password.length+1));
|
||||
mOS.write(password);
|
||||
mOS.write(0);
|
||||
outputBytes += password.length + 1;
|
||||
}
|
||||
mOS.write(PASSWORD_FIELD_TYPE);
|
||||
mOS.write(Types.writeInt(password.length+1));
|
||||
mOS.write(password);
|
||||
mOS.write(0);
|
||||
outputBytes += password.length + 1;
|
||||
|
||||
// Additional
|
||||
if (!EmptyUtils.isNullOrEmpty(mPE.additional)) {
|
||||
mOS.write(ADDITIONAL_FIELD_TYPE);
|
||||
int addlLen = Types.writeCString(mPE.additional, mOS);
|
||||
outputBytes += addlLen;
|
||||
}
|
||||
mOS.write(ADDITIONAL_FIELD_TYPE);
|
||||
int addlLen = Types.writeCString(mPE.additional, mOS);
|
||||
outputBytes += addlLen;
|
||||
|
||||
// Create date
|
||||
if (!EmptyUtils.isNullOrEmpty(mPE.tCreation)) {
|
||||
writeDate(CREATE_FIELD_TYPE, mPE.tCreation.getCDate());
|
||||
}
|
||||
writeDate(CREATE_FIELD_TYPE, mPE.tCreation.getCDate());
|
||||
|
||||
// Modification date
|
||||
if (!EmptyUtils.isNullOrEmpty(mPE.tLastMod)) {
|
||||
writeDate(MOD_FIELD_TYPE, mPE.tLastMod.getCDate());
|
||||
}
|
||||
writeDate(MOD_FIELD_TYPE, mPE.tLastMod.getCDate());
|
||||
|
||||
// Access date
|
||||
if (!EmptyUtils.isNullOrEmpty(mPE.tLastAccess)) {
|
||||
writeDate(ACCESS_FIELD_TYPE, mPE.tLastAccess.getCDate());
|
||||
}
|
||||
writeDate(ACCESS_FIELD_TYPE, mPE.tLastAccess.getCDate());
|
||||
|
||||
// Expiration date
|
||||
if (mPE.tExpire != null) {
|
||||
// Correct previously saved wrong expiry dates
|
||||
if (mPE.tExpire.equals(PwEntryV3.PW_NEVER_EXPIRE_BUG)) {
|
||||
mPE.tExpire = PwEntryV3.PW_NEVER_EXPIRE;
|
||||
}
|
||||
|
||||
writeDate(EXPIRE_FIELD_TYPE, mPE.tExpire.getCDate());
|
||||
}
|
||||
writeDate(EXPIRE_FIELD_TYPE, mPE.tExpire.getCDate());
|
||||
|
||||
// Binary desc
|
||||
if (!EmptyUtils.isNullOrEmpty(mPE.binaryDesc)) {
|
||||
mOS.write(BINARY_DESC_FIELD_TYPE);
|
||||
int descLen = Types.writeCString(mPE.binaryDesc, mOS);
|
||||
outputBytes += descLen;
|
||||
}
|
||||
mOS.write(BINARY_DESC_FIELD_TYPE);
|
||||
int descLen = Types.writeCString(mPE.binaryDesc, mOS);
|
||||
outputBytes += descLen;
|
||||
|
||||
// Binary data
|
||||
byte[] binaryData = mPE.getBinaryData();
|
||||
if (!EmptyUtils.isNullOrEmpty(binaryData)) {
|
||||
int dataLen = writeByteArray(binaryData);
|
||||
outputBytes += dataLen;
|
||||
}
|
||||
int dataLen = writeByteArray(mPE.getBinaryData());
|
||||
outputBytes += dataLen;
|
||||
|
||||
// End
|
||||
mOS.write(END_FIELD_TYPE);
|
||||
|
||||
@@ -22,9 +22,8 @@ package com.keepassdroid.database.save;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import com.keepassdroid.database.PwEntryV3;
|
||||
|
||||
import com.keepassdroid.database.PwGroupV3;
|
||||
import com.keepassdroid.utils.EmptyUtils;
|
||||
import com.keepassdroid.utils.Types;
|
||||
|
||||
public class PwGroupOutputV3 {
|
||||
@@ -68,49 +67,33 @@ public class PwGroupOutputV3 {
|
||||
mOS.write(Types.writeInt(mPG.groupId));
|
||||
|
||||
// Name
|
||||
if (!EmptyUtils.isNullOrEmpty(mPG.name)) {
|
||||
mOS.write(NAME_FIELD_TYPE);
|
||||
Types.writeCString(mPG.name, mOS);
|
||||
}
|
||||
mOS.write(NAME_FIELD_TYPE);
|
||||
Types.writeCString(mPG.name, mOS);
|
||||
|
||||
// Create date
|
||||
if (!EmptyUtils.isNullOrEmpty(mPG.tCreation)) {
|
||||
mOS.write(CREATE_FIELD_TYPE);
|
||||
mOS.write(DATE_FIELD_SIZE);
|
||||
mOS.write(mPG.tCreation.getCDate());
|
||||
}
|
||||
mOS.write(CREATE_FIELD_TYPE);
|
||||
mOS.write(DATE_FIELD_SIZE);
|
||||
mOS.write(mPG.tCreation.getCDate());
|
||||
|
||||
// Modification date
|
||||
if (!EmptyUtils.isNullOrEmpty(mPG.tLastMod)) {
|
||||
mOS.write(MOD_FIELD_TYPE);
|
||||
mOS.write(DATE_FIELD_SIZE);
|
||||
mOS.write(mPG.tLastMod.getCDate());
|
||||
}
|
||||
mOS.write(MOD_FIELD_TYPE);
|
||||
mOS.write(DATE_FIELD_SIZE);
|
||||
mOS.write(mPG.tLastMod.getCDate());
|
||||
|
||||
// Access date
|
||||
if (!EmptyUtils.isNullOrEmpty(mPG.tLastAccess)) {
|
||||
mOS.write(ACCESS_FIELD_TYPE);
|
||||
mOS.write(DATE_FIELD_SIZE);
|
||||
mOS.write(mPG.tLastAccess.getCDate());
|
||||
}
|
||||
mOS.write(ACCESS_FIELD_TYPE);
|
||||
mOS.write(DATE_FIELD_SIZE);
|
||||
mOS.write(mPG.tLastAccess.getCDate());
|
||||
|
||||
// Expiration date
|
||||
if (!EmptyUtils.isNullOrEmpty(mPG.tExpire)) {
|
||||
// Correct previously saved wrong expiry dates
|
||||
if (mPG.tExpire.equals(PwEntryV3.PW_NEVER_EXPIRE_BUG)) {
|
||||
mPG.tExpire = PwEntryV3.PW_NEVER_EXPIRE;
|
||||
}
|
||||
mOS.write(EXPIRE_FIELD_TYPE);
|
||||
mOS.write(DATE_FIELD_SIZE);
|
||||
mOS.write(mPG.tExpire.getCDate());
|
||||
}
|
||||
mOS.write(EXPIRE_FIELD_TYPE);
|
||||
mOS.write(DATE_FIELD_SIZE);
|
||||
mOS.write(mPG.tExpire.getCDate());
|
||||
|
||||
// Image ID
|
||||
if (mPG.icon != null) {
|
||||
mOS.write(IMAGEID_FIELD_TYPE);
|
||||
mOS.write(IMAGEID_FIELD_SIZE);
|
||||
mOS.write(Types.writeInt(mPG.icon.iconId));
|
||||
}
|
||||
mOS.write(IMAGEID_FIELD_TYPE);
|
||||
mOS.write(IMAGEID_FIELD_SIZE);
|
||||
mOS.write(Types.writeInt(mPG.icon.iconId));
|
||||
|
||||
// Level
|
||||
mOS.write(LEVEL_FIELD_TYPE);
|
||||
|
||||
Reference in New Issue
Block a user