mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-21 15:57:31 +09:00
Replace NSS with Pale Moon's
This commit is contained in:
parent
ff1e5e48bf
commit
8c2e376f94
2870 changed files with 1762232 additions and 1374220 deletions
|
|
@ -4,6 +4,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <limits.h>
|
||||
#include "prprf.h"
|
||||
#include "cert.h"
|
||||
#include "certi.h"
|
||||
|
|
@ -599,6 +600,8 @@ typedef enum {
|
|||
* Some callers will do quoting when needed, others will not.
|
||||
* If a caller selects minimalEscapeAndQuote, and the string does not
|
||||
* need quoting, then this function changes it to minimalEscape.
|
||||
* Limit source to 16K, which avoids any possibility of overflow.
|
||||
* Maximum output size would be 3*srclen+2.
|
||||
*/
|
||||
static int
|
||||
cert_RFC1485_GetRequiredLen(const char* src, int srclen, EQMode* pEQMode)
|
||||
|
|
@ -608,6 +611,10 @@ cert_RFC1485_GetRequiredLen(const char* src, int srclen, EQMode* pEQMode)
|
|||
PRBool needsQuoting = PR_FALSE;
|
||||
char lastC = 0;
|
||||
|
||||
/* avoids needing to check for overflow */
|
||||
if (srclen > 16384) {
|
||||
return -1;
|
||||
}
|
||||
/* need to make an initial pass to determine if quoting is needed */
|
||||
for (i = 0; i < srclen; i++) {
|
||||
char c = src[i];
|
||||
|
|
@ -637,6 +644,7 @@ cert_RFC1485_GetRequiredLen(const char* src, int srclen, EQMode* pEQMode)
|
|||
reqLen += 2;
|
||||
if (pEQMode && mode == minimalEscapeAndQuote && !needsQuoting)
|
||||
*pEQMode = minimalEscape;
|
||||
/* Maximum output size would be 3*srclen+2 */
|
||||
return reqLen;
|
||||
}
|
||||
|
||||
|
|
@ -648,12 +656,14 @@ escapeAndQuote(char* dst, int dstlen, char* src, int srclen, EQMode* pEQMode)
|
|||
int i, reqLen = 0;
|
||||
EQMode mode = pEQMode ? *pEQMode : minimalEscape;
|
||||
|
||||
reqLen = cert_RFC1485_GetRequiredLen(src, srclen, &mode);
|
||||
/* reqLen is max 16384*3 + 2 */
|
||||
/* space for terminal null */
|
||||
reqLen = cert_RFC1485_GetRequiredLen(src, srclen, &mode) + 1;
|
||||
if (reqLen > dstlen) {
|
||||
if (reqLen < 0 || reqLen + 1 > dstlen) {
|
||||
PORT_SetError(SEC_ERROR_OUTPUT_LEN);
|
||||
return SECFailure;
|
||||
}
|
||||
reqLen += 1;
|
||||
|
||||
if (mode == minimalEscapeAndQuote)
|
||||
*dst++ = C_DOUBLE_QUOTE;
|
||||
|
|
@ -836,6 +846,11 @@ get_hex_string(SECItem* data)
|
|||
static const char hex[] = { "0123456789ABCDEF" };
|
||||
|
||||
/* '#' + 2 chars per octet + terminator */
|
||||
/* Reject lengths that would overflow data->len * 2 + 2 in unsigned int. */
|
||||
if (data->len > (UINT_MAX - 2) / 2) {
|
||||
PORT_SetError(SEC_ERROR_INPUT_LEN);
|
||||
return NULL;
|
||||
}
|
||||
rv = SECITEM_AllocItem(NULL, NULL, data->len * 2 + 2);
|
||||
if (!rv) {
|
||||
return NULL;
|
||||
|
|
@ -981,9 +996,22 @@ AppendAVA(stringBuf* bufp, CERTAVA* ava, CertStrictnessLevel strict)
|
|||
}
|
||||
|
||||
nameLen = strlen(tagName);
|
||||
valueLen =
|
||||
(useHex ? avaValue->len : cert_RFC1485_GetRequiredLen(
|
||||
(char*)avaValue->data, avaValue->len, &mode));
|
||||
|
||||
if (useHex) {
|
||||
valueLen = avaValue->len;
|
||||
} else {
|
||||
int reqLen = cert_RFC1485_GetRequiredLen((char*)avaValue->data, avaValue->len, &mode);
|
||||
if (reqLen < 0) {
|
||||
SECITEM_FreeItem(avaValue, PR_TRUE);
|
||||
return SECFailure;
|
||||
}
|
||||
valueLen = reqLen;
|
||||
}
|
||||
if (UINT_MAX - nameLen < 2 ||
|
||||
valueLen > UINT_MAX - nameLen - 2) {
|
||||
SECITEM_FreeItem(avaValue, PR_TRUE);
|
||||
return SECFailure;
|
||||
}
|
||||
len = nameLen + valueLen + 2; /* Add 2 for '=' and trailing NUL */
|
||||
|
||||
maxName = nameLen;
|
||||
|
|
@ -1199,20 +1227,23 @@ avaToString(PLArenaPool* arena, CERTAVA* ava)
|
|||
if (!avaValue) {
|
||||
return buf;
|
||||
}
|
||||
valueLen =
|
||||
cert_RFC1485_GetRequiredLen((char*)avaValue->data, avaValue->len, NULL) + 1;
|
||||
if (arena) {
|
||||
buf = (char*)PORT_ArenaZAlloc(arena, valueLen);
|
||||
} else {
|
||||
buf = (char*)PORT_ZAlloc(valueLen);
|
||||
}
|
||||
if (buf) {
|
||||
SECStatus rv =
|
||||
escapeAndQuote(buf, valueLen, (char*)avaValue->data, avaValue->len, NULL);
|
||||
if (rv != SECSuccess) {
|
||||
if (!arena)
|
||||
PORT_Free(buf);
|
||||
buf = NULL;
|
||||
int reqLen = cert_RFC1485_GetRequiredLen((char*)avaValue->data, avaValue->len, NULL);
|
||||
/* reqLen is max 16384*3 + 2 */
|
||||
if (reqLen >= 0) {
|
||||
valueLen = reqLen + 1;
|
||||
if (arena) {
|
||||
buf = (char*)PORT_ArenaZAlloc(arena, valueLen);
|
||||
} else {
|
||||
buf = (char*)PORT_ZAlloc(valueLen);
|
||||
}
|
||||
if (buf) {
|
||||
SECStatus rv =
|
||||
escapeAndQuote(buf, valueLen, (char*)avaValue->data, avaValue->len, NULL);
|
||||
if (rv != SECSuccess) {
|
||||
if (!arena)
|
||||
PORT_Free(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
SECITEM_FreeItem(avaValue, PR_TRUE);
|
||||
|
|
@ -1490,7 +1521,7 @@ loser:
|
|||
** Caller should strdup or otherwise copy.
|
||||
*/
|
||||
const char* /* const so caller won't muck with it. */
|
||||
CERT_GetFirstEmailAddress(CERTCertificate* cert)
|
||||
CERT_GetFirstEmailAddress(CERTCertificate* cert)
|
||||
{
|
||||
if (cert && cert->emailAddr && cert->emailAddr[0])
|
||||
return (const char*)cert->emailAddr;
|
||||
|
|
@ -1502,7 +1533,7 @@ const char* /* const so caller won't muck with it. */
|
|||
** Caller should strdup or otherwise copy.
|
||||
*/
|
||||
const char* /* const so caller won't muck with it. */
|
||||
CERT_GetNextEmailAddress(CERTCertificate* cert, const char* prev)
|
||||
CERT_GetNextEmailAddress(CERTCertificate* cert, const char* prev)
|
||||
{
|
||||
if (cert && prev && prev[0]) {
|
||||
PRUint32 len = PL_strlen(prev);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue