diimdeep / 1P2KeePass

🔐 1Password (1pif) to 🔐 KeePass 2.x plugin 🔌
GNU General Public License v2.0
45 stars 11 forks source link

Crash on Import #2

Closed egooner closed 7 years ago

egooner commented 7 years ago

I have a strange crash on import whilst importing a Login record. I have copied the 1PIF data below obviously removing sensitive data

{"uuid":"UUID VALUE",
 "createdAt":1461778322727,                <-------------- This is bigger than usual!
 "updatedAt":1461778930,
 "title":"TITLE TEXT",
 "typeName":
 "webforms.WebForm",
 "securityLevel":"SL5",
 "openContents":{"contentsHash":"hashvalue","securityLevel":"SL5"},
 "contentsHash":"hashvalue",
 "secureContents":{
    "fields":[
        {"name":"Username","designation":"username","value":"usernamevalue"},
        {"name":"Password","designation":"password","value":"passwordvalue"}
    ],
    "notesPlain":"Some Text"
  }
}

As you can see for some reason the createdAt is represented in Milliseconds, this results in a crash at DateTimeExt at

dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();

I have no idea why this export contains that value as all the others seemed to be OK but I applied this simple fix to DateTimeExt.cs FromUnixTimeStamp to resolve in my local copy and wanted to share it with you.

                
if (unixTimeStamp > 20000000000)
{
    dtDateTime = dtDateTime.AddMilliseconds(unixTimeStamp).ToLocalTime();
}
else
{
    dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
}

If the value is < 20000000000 then a date up to 2603 can be supported, if greater than 20000000000 then it will assume Milliseconds and therefore an earliest date of Aug 1970.

diimdeep commented 7 years ago

Thanks