|
|
@ -484,19 +484,12 @@ return true; |
|
|
|
CEntry* PwDatabase::addEntry(CEntry* NewEntry){ |
|
|
|
CEntry* PwDatabase::addEntry(CEntry* NewEntry){ |
|
|
|
if(Entries.size()==0){ |
|
|
|
if(Entries.size()==0){ |
|
|
|
NewEntry->sID=0; |
|
|
|
NewEntry->sID=0; |
|
|
|
getRandomBytes(&NewEntry->ID,16,1,false); |
|
|
|
NewEntry->Uuid.generate(); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else{ |
|
|
|
NewEntry->sID=Entries.back().sID+1; |
|
|
|
NewEntry->sID=Entries.back().sID+1; |
|
|
|
while(1){ |
|
|
|
NewEntry->Uuid.generate(); |
|
|
|
bool used=false; |
|
|
|
} |
|
|
|
getRandomBytes(&NewEntry->ID,16,1,false); |
|
|
|
|
|
|
|
for(int j=0;j<Entries.size();j++){ |
|
|
|
|
|
|
|
int k; |
|
|
|
|
|
|
|
for(k=0;k<16;k++){if(Entries[j].ID[k]!=NewEntry->ID[k])k=0;break;} |
|
|
|
|
|
|
|
if(k==15)used=true;} |
|
|
|
|
|
|
|
if(used==false)break; |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
Entries.push_back(*NewEntry); |
|
|
|
Entries.push_back(*NewEntry); |
|
|
|
return &Entries.back(); |
|
|
|
return &Entries.back(); |
|
|
|
} |
|
|
|
} |
|
|
@ -506,19 +499,12 @@ CEntry* PwDatabase::addEntry(){ |
|
|
|
CEntry NewEntry; |
|
|
|
CEntry NewEntry; |
|
|
|
if(Entries.size()==0){ |
|
|
|
if(Entries.size()==0){ |
|
|
|
NewEntry.sID=0; |
|
|
|
NewEntry.sID=0; |
|
|
|
getRandomBytes(&NewEntry.ID,16,1,false); |
|
|
|
NewEntry.Uuid.generate(); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else{ |
|
|
|
|
|
|
|
NewEntry.Uuid.generate(); |
|
|
|
NewEntry.sID=Entries.back().sID+1; |
|
|
|
NewEntry.sID=Entries.back().sID+1; |
|
|
|
while(1){ |
|
|
|
} |
|
|
|
bool used=false; |
|
|
|
|
|
|
|
getRandomBytes(&NewEntry.ID,16,1,false); |
|
|
|
|
|
|
|
for(int j=0;j<Entries.size();j++){ |
|
|
|
|
|
|
|
int k; |
|
|
|
|
|
|
|
for(k=0;k<16;k++){if(Entries[j].ID[k]!=NewEntry.ID[k])k=0;break;} |
|
|
|
|
|
|
|
if(k==15)used=true;} |
|
|
|
|
|
|
|
if(used==false)break; |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
Entries.push_back(NewEntry); |
|
|
|
Entries.push_back(NewEntry); |
|
|
|
return &Entries.back(); |
|
|
|
return &Entries.back(); |
|
|
|
} |
|
|
|
} |
|
|
@ -612,12 +598,10 @@ entry->GroupID=dst->ID; |
|
|
|
|
|
|
|
|
|
|
|
CEntry* PwDatabase::cloneEntry(CEntry* entry){ |
|
|
|
CEntry* PwDatabase::cloneEntry(CEntry* entry){ |
|
|
|
CEntry *Dolly=addEntry(); |
|
|
|
CEntry *Dolly=addEntry(); |
|
|
|
quint8 ID[16]; |
|
|
|
|
|
|
|
quint32 sid=Dolly->sID; |
|
|
|
quint32 sid=Dolly->sID; |
|
|
|
memcpy(ID,Dolly->ID,16); |
|
|
|
|
|
|
|
*Dolly=*entry; |
|
|
|
*Dolly=*entry; |
|
|
|
Dolly->sID=sid; |
|
|
|
Dolly->sID=sid; |
|
|
|
memcpy(Dolly->ID,ID,16); |
|
|
|
Dolly->Uuid.generate(); |
|
|
|
return Dolly; |
|
|
|
return Dolly; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -685,7 +669,7 @@ switch(FieldType) |
|
|
|
// Ignore field
|
|
|
|
// Ignore field
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case 0x0001: |
|
|
|
case 0x0001: |
|
|
|
memcpy(ID, pData, 16); |
|
|
|
Uuid=KpxUuid(pData); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 0x0002: |
|
|
|
case 0x0002: |
|
|
|
memcpyFromLEnd32(&GroupID, (char*)pData); |
|
|
|
memcpyFromLEnd32(&GroupID, (char*)pData); |
|
|
@ -894,7 +878,7 @@ for(int i = 0; i < Entries.size(); i++){ |
|
|
|
FieldType = 0x0001; FieldSize = 16; |
|
|
|
FieldType = 0x0001; FieldSize = 16; |
|
|
|
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; |
|
|
|
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; |
|
|
|
memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4; |
|
|
|
memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4; |
|
|
|
memcpy(buffer+pos, &Entries[i].ID, 16); pos += 16; |
|
|
|
Entries[i].Uuid.toRaw(buffer+pos); pos += 16; |
|
|
|
|
|
|
|
|
|
|
|
FieldType = 0x0002; FieldSize = 4; |
|
|
|
FieldType = 0x0002; FieldSize = 4; |
|
|
|
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; |
|
|
|
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; |
|
|
@ -982,7 +966,7 @@ for(int i = 0; i < MetaStreams.size(); i++){ |
|
|
|
FieldType = 0x0001; FieldSize = 16; |
|
|
|
FieldType = 0x0001; FieldSize = 16; |
|
|
|
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; |
|
|
|
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; |
|
|
|
memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4; |
|
|
|
memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4; |
|
|
|
memcpy(buffer+pos, &MetaStreams[i]->ID, 16); pos += 16; |
|
|
|
MetaStreams[i]->Uuid.toRaw(buffer+pos); pos += 16; |
|
|
|
|
|
|
|
|
|
|
|
FieldType = 0x0002; FieldSize = 4; |
|
|
|
FieldType = 0x0002; FieldSize = 4; |
|
|
|
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; |
|
|
|
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; |
|
|
@ -1528,8 +1512,8 @@ void assertGroupsEq(KPTestResults& results, CGroup* left, CGroup* right){ |
|
|
|
void assertEntriesEq(KPTestResults& results, CEntry* left, CEntry* right){ |
|
|
|
void assertEntriesEq(KPTestResults& results, CEntry* left, CEntry* right){ |
|
|
|
unsigned long size = 0; |
|
|
|
unsigned long size = 0; |
|
|
|
|
|
|
|
|
|
|
|
kp_assert(results, memcmp(left->ID, right->ID, sizeof(left->ID)) == 0); |
|
|
|
kp_assert(results, left->Uuid==right->Uuid); |
|
|
|
size += sizeof(left->ID); |
|
|
|
size += sizeof(left->Uuid); |
|
|
|
|
|
|
|
|
|
|
|
kp_assert(results, left->sID == right->sID); |
|
|
|
kp_assert(results, left->sID == right->sID); |
|
|
|
size += sizeof(left->sID); |
|
|
|
size += sizeof(left->sID); |
|
|
|