зеркало из https://github.com/mozilla/pjs.git
remove buggy support for old file format, bug 26561
This commit is contained in:
Родитель
1d85a84ca7
Коммит
4f7cdbdc74
|
@ -456,10 +456,8 @@ static const char *pref_rememberSignons = "signon.rememberSignons";
|
||||||
#ifdef DefaultIsOff
|
#ifdef DefaultIsOff
|
||||||
static const char *pref_Notified = "signon.Notified";
|
static const char *pref_Notified = "signon.Notified";
|
||||||
#endif
|
#endif
|
||||||
static const char *pref_SignonFileName = "signon.SignonFileName"; /* for old format only */
|
|
||||||
static const char *pref_SignonFileNameP = "signon.SignonPasswordFileName";
|
static const char *pref_SignonFileNameP = "signon.SignonPasswordFileName";
|
||||||
static const char *pref_SignonFileNameU = "signon.SignonURLFileName";
|
static const char *pref_SignonFileNameU = "signon.SignonURLFileName";
|
||||||
static PRBool si_oldFormat = PR_FALSE;
|
|
||||||
|
|
||||||
PRIVATE PRBool si_RememberSignons = PR_FALSE;
|
PRIVATE PRBool si_RememberSignons = PR_FALSE;
|
||||||
#ifdef DefaultIsOff
|
#ifdef DefaultIsOff
|
||||||
|
@ -565,41 +563,15 @@ extern char* Wallet_RandomName(char* suffix);
|
||||||
|
|
||||||
PUBLIC void
|
PUBLIC void
|
||||||
SI_InitSignonFileName() {
|
SI_InitSignonFileName() {
|
||||||
/*
|
|
||||||
* All files created by wallet and single signon will have a format designation number
|
|
||||||
* in the first line of the file. However the original files did not do that. So we
|
|
||||||
* go to great pains to maintain backwards compatibility with these old files. We
|
|
||||||
* accomplish this by changing the names of the old files.
|
|
||||||
*
|
|
||||||
* The original and new names of the files are:
|
|
||||||
*
|
|
||||||
* old names new names
|
|
||||||
* key file: xxxxxxxx.key xxxxxxxx.k
|
|
||||||
* wallet data: xxxxxxxx.wlt xxxxxxxx.w
|
|
||||||
* ss passwords: xxxxxxxx.psw xxxxxxxx.p
|
|
||||||
* ss urls: signon.tab xxxxxxxx.u
|
|
||||||
*
|
|
||||||
* Furtherore, the names of the first three files were stored in prefs.js for the old
|
|
||||||
* files but all four are stored there for the new ones.
|
|
||||||
*/
|
|
||||||
SI_GetCharPref(pref_SignonFileNameP, &signonFileNameP);
|
SI_GetCharPref(pref_SignonFileNameP, &signonFileNameP);
|
||||||
|
|
||||||
if (!signonFileNameP) {
|
if (!signonFileNameP) {
|
||||||
SI_GetCharPref(pref_SignonFileName, &signonFileNameP);
|
signonFileNameP = Wallet_RandomName("p");
|
||||||
if (!signonFileNameP) {
|
SI_SetCharPref(pref_SignonFileNameP, signonFileNameP);
|
||||||
signonFileNameP = Wallet_RandomName("p");
|
|
||||||
SI_SetCharPref(pref_SignonFileNameP, signonFileNameP);
|
|
||||||
} else {
|
|
||||||
si_oldFormat = PR_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
SI_GetCharPref(pref_SignonFileNameU, &signonFileNameU);
|
||||||
if (!si_oldFormat) {
|
if (!signonFileNameU) {
|
||||||
SI_GetCharPref(pref_SignonFileNameU, &signonFileNameU);
|
signonFileNameU = Wallet_RandomName("u");
|
||||||
if (!signonFileNameU) {
|
SI_SetCharPref(pref_SignonFileNameU, signonFileNameU);
|
||||||
signonFileNameU = Wallet_RandomName("u");
|
|
||||||
SI_SetCharPref(pref_SignonFileNameU, signonFileNameU);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1772,10 +1744,7 @@ SI_LoadSignonData(PRBool fullLoad) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SI_InitSignonFileName();
|
SI_InitSignonFileName();
|
||||||
nsInputFileStream strmu(dirSpec+"signon.tbl");
|
nsInputFileStream strmu(dirSpec+signonFileNameU);
|
||||||
if (!si_oldFormat) {
|
|
||||||
strmu = nsInputFileStream(dirSpec+signonFileNameU);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strmu.is_open()) {
|
if (!strmu.is_open()) {
|
||||||
/* this means no data was previously saved, so we must be fully loaded at this time */
|
/* this means no data was previously saved, so we must be fully loaded at this time */
|
||||||
|
@ -1810,48 +1779,45 @@ SI_LoadSignonData(PRBool fullLoad) {
|
||||||
nsKeyType temp;
|
nsKeyType temp;
|
||||||
PRInt32 error;
|
PRInt32 error;
|
||||||
|
|
||||||
if (!si_oldFormat) {
|
/* format */
|
||||||
|
|
||||||
/* format */
|
if (NS_FAILED(si_ReadLine(strmu, strmp, format, fullLoad, 0, 0, PR_TRUE))) {
|
||||||
|
return -1;
|
||||||
if (NS_FAILED(si_ReadLine(strmu, strmp, format, fullLoad, 0, 0, PR_TRUE))) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (format != HEADER_VERSION_1) {
|
|
||||||
/* something's wrong */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* saveCount */
|
|
||||||
|
|
||||||
if (NS_FAILED(si_ReadLine(strmu, strmp, buffer, fullLoad, 0, 0, PR_TRUE))) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (NS_FAILED(si_ReadLine(strmu, strmp, buffer, fullLoad, 0, 0, PR_TRUE))) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
temp = (nsKeyType)(buffer.ToInteger(&error));
|
|
||||||
if (error) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
saveCountP = temp;
|
|
||||||
|
|
||||||
/* readCount */
|
|
||||||
|
|
||||||
if (NS_FAILED(si_ReadLine(strmu, strmp, buffer, fullLoad, 0, 0, PR_TRUE))) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (NS_FAILED(si_ReadLine(strmu, strmp, buffer, fullLoad, 0, 0, PR_TRUE))) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
temp = (nsKeyType)(buffer.ToInteger(&error));
|
|
||||||
if (error) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
readCount = temp;
|
|
||||||
|
|
||||||
Wallet_StreamGeneratorReset();
|
|
||||||
}
|
}
|
||||||
|
if (format != HEADER_VERSION_1) {
|
||||||
|
/* something's wrong */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* saveCount */
|
||||||
|
|
||||||
|
if (NS_FAILED(si_ReadLine(strmu, strmp, buffer, fullLoad, 0, 0, PR_TRUE))) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (NS_FAILED(si_ReadLine(strmu, strmp, buffer, fullLoad, 0, 0, PR_TRUE))) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
temp = (nsKeyType)(buffer.ToInteger(&error));
|
||||||
|
if (error) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
saveCountP = temp;
|
||||||
|
|
||||||
|
/* readCount */
|
||||||
|
|
||||||
|
if (NS_FAILED(si_ReadLine(strmu, strmp, buffer, fullLoad, 0, 0, PR_TRUE))) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (NS_FAILED(si_ReadLine(strmu, strmp, buffer, fullLoad, 0, 0, PR_TRUE))) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
temp = (nsKeyType)(buffer.ToInteger(&error));
|
||||||
|
if (error) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
readCount = temp;
|
||||||
|
|
||||||
|
Wallet_StreamGeneratorReset();
|
||||||
|
|
||||||
/* read the reject list */
|
/* read the reject list */
|
||||||
si_lock_signon_list();
|
si_lock_signon_list();
|
||||||
|
@ -1861,14 +1827,6 @@ SI_LoadSignonData(PRBool fullLoad) {
|
||||||
}
|
}
|
||||||
si_StripLF(buffer);
|
si_StripLF(buffer);
|
||||||
URLName = buffer.ToNewCString();
|
URLName = buffer.ToNewCString();
|
||||||
if (si_oldFormat) {
|
|
||||||
if (NS_FAILED(si_ReadLine(strmu, strmp, buffer, PR_FALSE))) {
|
|
||||||
/* error in input file so give up */
|
|
||||||
badInput = PR_TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
si_StripLF(buffer);
|
|
||||||
}
|
|
||||||
si_PutReject(URLName, buffer, PR_FALSE); /* middle parameter is obsolete */
|
si_PutReject(URLName, buffer, PR_FALSE); /* middle parameter is obsolete */
|
||||||
Recycle (URLName);
|
Recycle (URLName);
|
||||||
}
|
}
|
||||||
|
@ -1906,11 +1864,7 @@ SI_LoadSignonData(PRBool fullLoad) {
|
||||||
} else {
|
} else {
|
||||||
isPassword = PR_FALSE;
|
isPassword = PR_FALSE;
|
||||||
name = buffer;
|
name = buffer;
|
||||||
if (si_oldFormat) {
|
ret = si_ReadLine(strmu, strmp, buffer, fullLoad, saveCountP, &readCount);
|
||||||
ret = si_ReadLine(strmu, strmp, buffer, PR_FALSE);
|
|
||||||
} else {
|
|
||||||
ret = si_ReadLine(strmu, strmp, buffer, fullLoad, saveCountP, &readCount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read in and save the value part */
|
/* read in and save the value part */
|
||||||
|
@ -2007,14 +1961,13 @@ si_SaveSignonDataLocked(PRBool fullSave) {
|
||||||
si_SignonDataStruct * data;
|
si_SignonDataStruct * data;
|
||||||
si_Reject * reject;
|
si_Reject * reject;
|
||||||
nsKeyType writeCount = 0;
|
nsKeyType writeCount = 0;
|
||||||
PRBool fullSave2 = fullSave || si_oldFormat;
|
|
||||||
|
|
||||||
/* do nothing if signon list has not changed */
|
/* do nothing if signon list has not changed */
|
||||||
if(!si_signon_list_changed) {
|
if(!si_signon_list_changed) {
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullSave2) {
|
if (fullSave) {
|
||||||
PRUnichar * message = Wallet_Localize("IncorrectKey_TryAgain?");
|
PRUnichar * message = Wallet_Localize("IncorrectKey_TryAgain?");
|
||||||
if (si_KeyTimedOut()) {
|
if (si_KeyTimedOut()) {
|
||||||
SI_RemoveAllSignonData();
|
SI_RemoveAllSignonData();
|
||||||
|
@ -2047,27 +2000,13 @@ si_SaveSignonDataLocked(PRBool fullSave) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (si_oldFormat) {
|
|
||||||
|
|
||||||
/* change name of signonFileNameP from "xxxxxxxx.psw" to "xxxxxxxx.p" */
|
|
||||||
signonFileNameP[10] = '\0';
|
|
||||||
SI_SetCharPref(pref_SignonFileNameP, signonFileNameP);
|
|
||||||
|
|
||||||
/* create signonFileNameU and set it to "xxxxxxxx.u" */
|
|
||||||
signonFileNameU = PL_strdup(signonFileNameP); /* set it to "xxxxxxxx.p" */
|
|
||||||
signonFileNameU[9] = 'u'; /* change .p to .u */
|
|
||||||
SI_SetCharPref(pref_SignonFileNameU, signonFileNameU);
|
|
||||||
|
|
||||||
si_oldFormat = PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsOutputFileStream strmu(dirSpec + signonFileNameU);
|
nsOutputFileStream strmu(dirSpec + signonFileNameU);
|
||||||
if (!strmu.is_open()) {
|
if (!strmu.is_open()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
nsOutputFileStream strmp
|
nsOutputFileStream strmp
|
||||||
(fullSave2 ? (dirSpec+signonFileNameP) : dirSpec); // not used if !fullSave
|
(fullSave ? (dirSpec+signonFileNameP) : dirSpec); // not used if !fullSave
|
||||||
if (fullSave2 && !strmp.is_open()) {
|
if (fullSave && !strmp.is_open()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2084,7 +2023,7 @@ si_SaveSignonDataLocked(PRBool fullSave) {
|
||||||
|
|
||||||
/* format revision number */
|
/* format revision number */
|
||||||
|
|
||||||
si_WriteLine(strmu, strmp, nsAutoString(HEADER_VERSION_1), PR_FALSE, fullSave2, 0, 0, PR_TRUE);
|
si_WriteLine(strmu, strmp, nsAutoString(HEADER_VERSION_1), PR_FALSE, fullSave, 0, 0, PR_TRUE);
|
||||||
|
|
||||||
/* saveCount */
|
/* saveCount */
|
||||||
|
|
||||||
|
@ -2092,15 +2031,15 @@ si_SaveSignonDataLocked(PRBool fullSave) {
|
||||||
buffer = "";
|
buffer = "";
|
||||||
saveCountP += 16; /* preserve low order four bits which designate the file type */
|
saveCountP += 16; /* preserve low order four bits which designate the file type */
|
||||||
buffer.Append(PRInt32(saveCountP),10);
|
buffer.Append(PRInt32(saveCountP),10);
|
||||||
si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE);
|
si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave, 0, 0, PR_TRUE);
|
||||||
si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE);
|
si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave, 0, 0, PR_TRUE);
|
||||||
|
|
||||||
/* writeCount */
|
/* writeCount */
|
||||||
|
|
||||||
buffer = "";
|
buffer = "";
|
||||||
buffer.Append(PRInt32(writeCount),10);
|
buffer.Append(PRInt32(writeCount),10);
|
||||||
si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE);
|
si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave, 0, 0, PR_TRUE);
|
||||||
si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave2, 0, 0, PR_TRUE);
|
si_WriteLine(strmu, strmp, buffer, PR_FALSE, fullSave, 0, 0, PR_TRUE);
|
||||||
|
|
||||||
Wallet_StreamGeneratorReset();
|
Wallet_StreamGeneratorReset();
|
||||||
|
|
||||||
|
@ -2118,10 +2057,10 @@ si_SaveSignonDataLocked(PRBool fullSave) {
|
||||||
PRInt32 rejectCount = LIST_COUNT(si_reject_list);
|
PRInt32 rejectCount = LIST_COUNT(si_reject_list);
|
||||||
for (PRInt32 i=0; i<rejectCount; i++) {
|
for (PRInt32 i=0; i<rejectCount; i++) {
|
||||||
reject = NS_STATIC_CAST(si_Reject*, si_reject_list->ElementAt(i));
|
reject = NS_STATIC_CAST(si_Reject*, si_reject_list->ElementAt(i));
|
||||||
si_WriteLine(strmu, strmp, nsAutoString(reject->URLName), PR_FALSE, fullSave2);
|
si_WriteLine(strmu, strmp, nsAutoString(reject->URLName), PR_FALSE, fullSave);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
si_WriteLine(strmu, strmp, nsAutoString("."), PR_FALSE, fullSave2);
|
si_WriteLine(strmu, strmp, nsAutoString("."), PR_FALSE, fullSave);
|
||||||
|
|
||||||
/* format for cached logins shall be:
|
/* format for cached logins shall be:
|
||||||
* url LINEBREAK {name LINEBREAK value LINEBREAK}* . LINEBREAK
|
* url LINEBREAK {name LINEBREAK value LINEBREAK}* . LINEBREAK
|
||||||
|
@ -2139,7 +2078,7 @@ si_SaveSignonDataLocked(PRBool fullSave) {
|
||||||
for (PRInt32 i3=0; i3<userCount; i3++) {
|
for (PRInt32 i3=0; i3<userCount; i3++) {
|
||||||
user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(i3));
|
user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(i3));
|
||||||
si_WriteLine
|
si_WriteLine
|
||||||
(strmu, strmp, nsAutoString(url->URLName), PR_FALSE, fullSave2);
|
(strmu, strmp, nsAutoString(url->URLName), PR_FALSE, fullSave);
|
||||||
|
|
||||||
/* write out each data node of the user node */
|
/* write out each data node of the user node */
|
||||||
PRInt32 dataCount = LIST_COUNT(user->signonData_list);
|
PRInt32 dataCount = LIST_COUNT(user->signonData_list);
|
||||||
|
@ -2148,18 +2087,18 @@ si_SaveSignonDataLocked(PRBool fullSave) {
|
||||||
if (data->isPassword) {
|
if (data->isPassword) {
|
||||||
si_WriteChar(strmu, '*');
|
si_WriteChar(strmu, '*');
|
||||||
}
|
}
|
||||||
si_WriteLine(strmu, strmp, nsAutoString(data->name), PR_FALSE, fullSave2);
|
si_WriteLine(strmu, strmp, nsAutoString(data->name), PR_FALSE, fullSave);
|
||||||
si_WriteLine(strmu, strmp, nsAutoString(data->value), PR_TRUE,
|
si_WriteLine(strmu, strmp, nsAutoString(data->value), PR_TRUE,
|
||||||
fullSave2, saveCountP, &writeCount);
|
fullSave, saveCountP, &writeCount);
|
||||||
}
|
}
|
||||||
si_WriteLine(strmu, strmp, nsAutoString("."), PR_FALSE, fullSave2);
|
si_WriteLine(strmu, strmp, nsAutoString("."), PR_FALSE, fullSave);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
si_signon_list_changed = PR_FALSE;
|
si_signon_list_changed = PR_FALSE;
|
||||||
strmu.flush();
|
strmu.flush();
|
||||||
strmu.close();
|
strmu.close();
|
||||||
if (fullSave2) {
|
if (fullSave) {
|
||||||
strmp.flush();
|
strmp.flush();
|
||||||
strmp.close();
|
strmp.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,8 +350,6 @@ typedef struct _wallet_PrefillElement {
|
||||||
|
|
||||||
nsIURI * wallet_lastUrl = NULL;
|
nsIURI * wallet_lastUrl = NULL;
|
||||||
|
|
||||||
static PRBool wallet_oldFormat = PR_FALSE;
|
|
||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* The following routines are for diagnostic purposes only */
|
/* The following routines are for diagnostic purposes only */
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
|
@ -1553,8 +1551,6 @@ wallet_InitKeyFileName() {
|
||||||
if (!schemaValueFileName) {
|
if (!schemaValueFileName) {
|
||||||
schemaValueFileName = Wallet_RandomName("w");
|
schemaValueFileName = Wallet_RandomName("w");
|
||||||
SI_SetCharPref(pref_WalletSchemaValueFileName, schemaValueFileName);
|
SI_SetCharPref(pref_WalletSchemaValueFileName, schemaValueFileName);
|
||||||
} else if (PL_strstr(schemaValueFileName, ".wlt")) {
|
|
||||||
wallet_oldFormat = PR_TRUE;
|
|
||||||
}
|
}
|
||||||
SI_InitSignonFileName();
|
SI_InitSignonFileName();
|
||||||
namesInitialized = PR_TRUE;
|
namesInitialized = PR_TRUE;
|
||||||
|
@ -1984,13 +1980,6 @@ wallet_WriteToFile(const char * filename, nsVoidArray* list, PRBool obscure) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename == schemaValueFileName && wallet_oldFormat) {
|
|
||||||
/* change name of schemaValueFileName file from "xxxxxxxx.wlt" to "xxxxxxxx.w" */
|
|
||||||
schemaValueFileName[10] = '\0';
|
|
||||||
SI_SetCharPref(pref_WalletSchemaValueFileName, schemaValueFileName);
|
|
||||||
wallet_oldFormat = PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsOutputFileStream strm(dirSpec + filename);
|
nsOutputFileStream strm(dirSpec + filename);
|
||||||
if (!strm.is_open()) {
|
if (!strm.is_open()) {
|
||||||
NS_ERROR("unable to open file");
|
NS_ERROR("unable to open file");
|
||||||
|
@ -2058,7 +2047,7 @@ wallet_ReadFromFile
|
||||||
nsKeyType readCount = 0;
|
nsKeyType readCount = 0;
|
||||||
|
|
||||||
/* read in the header */
|
/* read in the header */
|
||||||
if (filename == schemaValueFileName && !wallet_oldFormat) {
|
if (filename == schemaValueFileName) {
|
||||||
wallet_GetHeader(strm, saveCountW, readCount);
|
wallet_GetHeader(strm, saveCountW, readCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3301,13 +3290,6 @@ WLLT_PostEdit(nsAutoString walletList) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wallet_oldFormat) {
|
|
||||||
/* change name of schemaValueFileName file from "xxxxxxxx.wlt" to "xxxxxxxx.w" */
|
|
||||||
schemaValueFileName[10] = '\0';
|
|
||||||
SI_SetCharPref(pref_WalletSchemaValueFileName, schemaValueFileName);
|
|
||||||
wallet_oldFormat = PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open SchemaValue file */
|
/* open SchemaValue file */
|
||||||
nsOutputFileStream strm(dirSpec + schemaValueFileName);
|
nsOutputFileStream strm(dirSpec + schemaValueFileName);
|
||||||
if (!strm.is_open()) {
|
if (!strm.is_open()) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче