Bug 1194692 - fix fallback values at callsites of fileTimeToSecondsSinceEpoch, r=MattN

--HG--
extra : commitid : K0lsNv1Ppkp
extra : rebase_source : 287103131b503124081470fd6549b4a1d6a4395e
extra : histedit_source : 4b12850bec32148d0713fc5fa8fff9f4a910a4d7
This commit is contained in:
Gijs Kruitbosch 2015-09-22 23:25:28 +01:00
Родитель 49f914d2d7
Коммит 267695d771
1 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -686,8 +686,9 @@ Cookies.prototype = {
host = "." + host;
}
// Fallback: expire in 1h
let expireTime = (Date.now() + 3600 * 1000) * 1000;
// Fallback: expire in 1h (NB: time is in seconds since epoch, so we have
// to divide the result of Date.now() (which is in milliseconds) by 1000).
let expireTime = Math.floor(Date.now() / 1000) + 3600;
try {
expireTime = this.ctypesKernelHelpers.fileTimeToSecondsSinceEpoch(Number(expireTimeHi),
Number(expireTimeLo));
@ -751,10 +752,14 @@ function getTypedURLs(registryKeyPath) {
try {
let hi = parseInt(urlTimeHex.slice(0, 4).join(''), 16);
let lo = parseInt(urlTimeHex.slice(4, 8).join(''), 16);
// Convert to seconds since epoch:
timeTyped = cTypes.fileTimeToSecondsSinceEpoch(hi, lo);
// Callers expect PRTime, which is microseconds since epoch:
timeTyped *= 1000 * 1000;
} catch (ex) {}
} catch (ex) {
// Ignore conversion exceptions. Callers will have to deal
// with the fallback value (0).
}
}
}
typedURLs.set(url, timeTyped);
@ -862,9 +867,16 @@ WindowsVaultFormPasswords.prototype = {
}
let password = credential.contents.pAuthenticatorElement.contents.itemValue.readString();
let creation = ctypesKernelHelpers.
let creation = Date.now();
try {
// login manager wants time in milliseconds since epoch, so convert
// to seconds since epoch and multiply to get milliseconds:
creation = ctypesKernelHelpers.
fileTimeToSecondsSinceEpoch(item.contents.highLastModified,
item.contents.lowLastModified) * 1000;
} catch (ex) {
// Ignore exceptions in the dates and just create the login for right now.
}
// create a new login
let login = {
username, password,