mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 682244 - Change CRL autoupdate pref from formatted date to integer. sr=bsmith r=kaie
This commit is contained in:
parent
34b9df2a69
commit
4f51162934
@ -38,8 +38,6 @@
|
||||
#include "nsCRLInfo.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsNSSComponent.h"
|
||||
@ -259,18 +257,16 @@ done:
|
||||
bool toBeRescheduled = false;
|
||||
if(NS_SUCCEEDED(ComputeNextAutoUpdateTime(crlData, timingTypePref, dayCnt, &updateTime))){
|
||||
updateTimeStr.AssignWithConversion(updateTime);
|
||||
nsMemory::Free(updateTime);
|
||||
pref->SetCharPref(updateTimePrefStr.get(),updateTimeStr.get());
|
||||
//Now, check if this update time is already in the past. This would
|
||||
//imply we have downloaded the same crl, or there is something wrong
|
||||
//with the next update date. We will not reschedule this crl in this
|
||||
//session anymore - or else, we land into a loop. It would anyway be
|
||||
//imported once the browser is restarted.
|
||||
PRTime nextTime;
|
||||
PR_ParseTimeString(updateTimeStr.get(),true, &nextTime);
|
||||
if(LL_CMP(nextTime, > , PR_Now())){
|
||||
if(LL_CMP(updateTime, > , PR_Now())){
|
||||
toBeRescheduled = true;
|
||||
}
|
||||
nsMemory::Free(updateTime);
|
||||
}
|
||||
|
||||
//Update the url to download from, next time
|
||||
@ -419,6 +415,7 @@ nsCRLManager::ComputeNextAutoUpdateTime(nsICRLInfo *info,
|
||||
{
|
||||
if (!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_ARG_POINTER(nextAutoUpdate);
|
||||
|
||||
PRTime microsecInDayCnt;
|
||||
PRTime now = PR_Now();
|
||||
@ -474,15 +471,10 @@ nsCRLManager::ComputeNextAutoUpdateTime(nsICRLInfo *info,
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString nextAutoUpdateDate;
|
||||
PRExplodedTime explodedTime;
|
||||
nsCOMPtr<nsIDateTimeFormat> dateFormatter = do_CreateInstance(NS_DATETIMEFORMAT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
PR_ExplodeTime(tempTime, PR_GMTParameters, &explodedTime);
|
||||
dateFormatter->FormatPRExplodedTime(nsnull, kDateFormatShort, kTimeFormatSeconds,
|
||||
&explodedTime, nextAutoUpdateDate);
|
||||
*nextAutoUpdate = ToNewUnicode(nextAutoUpdateDate);
|
||||
// Return value as string; no pref type for Int64/PRTime
|
||||
char *tempTimeStr = PR_smprintf("%lli", tempTime);
|
||||
*nextAutoUpdate = ToNewUnicode(nsDependentCString(tempTimeStr));
|
||||
PR_smprintf_free(tempTimeStr);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1324,14 +1324,41 @@ nsresult nsNSSComponent::getParamsForNextCrlToDownload(nsAutoString *url, PRTime
|
||||
PRTime tempTime;
|
||||
nsCAutoString timingPrefCString(updateTimePref);
|
||||
timingPrefCString.AppendWithConversion(tempCrlKey);
|
||||
// No PRTime/Int64 type in prefs; stored as string; parsed here as PRInt64
|
||||
rv = pref->GetCharPref(timingPrefCString.get(), &tempTimeString);
|
||||
if (NS_FAILED(rv)){
|
||||
continue;
|
||||
}
|
||||
rv = PR_ParseTimeString(tempTimeString,true, &tempTime);
|
||||
nsMemory::Free(tempTimeString);
|
||||
if (NS_FAILED(rv)){
|
||||
continue;
|
||||
// Assume corrupted. Force download. Pref should be reset after download.
|
||||
tempTime = PR_Now();
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG,
|
||||
("get %s failed: forcing download\n", timingPrefCString.get()));
|
||||
} else {
|
||||
tempTime = (PRTime)nsCRT::atoll(tempTimeString);
|
||||
nsMemory::Free(tempTimeString);
|
||||
// nsCRT::atoll parses the first token in the string; three possibilities
|
||||
// -1- Alpha char: returns 0; change to PR_Now() and force update.
|
||||
// -2- Number (between epoch and PR_Now(), e.g. 0 - 1332280017 for
|
||||
// Tue Mar 20, 2012, 2:46pm approx): includes formatted date
|
||||
// values (previous method of storing update date, e.g year, month
|
||||
// or day, 2012, 1-31, 1-12 etc). Less than PR_Now() forces
|
||||
// autoupdate.
|
||||
// -3- Number (larger than PR_Now()): no forced autoupdate
|
||||
// Note: corrupt values within range of -2- will have an implicit
|
||||
// unflagged recovery. Corrupt values in range of -3- will be unflagged
|
||||
// and unrecovered by this code.
|
||||
if (tempTime == 0)
|
||||
tempTime = PR_Now();
|
||||
#ifdef PR_LOGGING
|
||||
PRExplodedTime explodedTime;
|
||||
PR_ExplodeTime(tempTime, PR_GMTParameters, &explodedTime);
|
||||
// Note: tm_month starts from 0 = Jan, hence +1
|
||||
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG,
|
||||
("%s tempTime(%lli) "
|
||||
"(m/d/y h:m:s = %02d/%02d/%d %02d:%02d:%02d GMT\n",
|
||||
timingPrefCString.get(), tempTime,
|
||||
explodedTime.tm_month+1, explodedTime.tm_mday,
|
||||
explodedTime.tm_year, explodedTime.tm_hour,
|
||||
explodedTime.tm_min, explodedTime.tm_sec));
|
||||
#endif
|
||||
}
|
||||
|
||||
if(nearestUpdateTime == 0 || tempTime < nearestUpdateTime){
|
||||
|
Loading…
Reference in New Issue
Block a user