mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-23 00:47:31 +09:00
re-introduce old nss im too tired for this
This commit is contained in:
parent
3c46be320d
commit
3a838106b9
2871 changed files with 1374431 additions and 1762417 deletions
|
|
@ -4,7 +4,6 @@
|
|||
* 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"
|
||||
|
|
@ -600,8 +599,6 @@ 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)
|
||||
|
|
@ -611,10 +608,6 @@ 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];
|
||||
|
|
@ -644,7 +637,6 @@ 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;
|
||||
}
|
||||
|
||||
|
|
@ -656,14 +648,12 @@ 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 */
|
||||
if (reqLen < 0 || reqLen + 1 > dstlen) {
|
||||
reqLen = cert_RFC1485_GetRequiredLen(src, srclen, &mode) + 1;
|
||||
if (reqLen > dstlen) {
|
||||
PORT_SetError(SEC_ERROR_OUTPUT_LEN);
|
||||
return SECFailure;
|
||||
}
|
||||
reqLen += 1;
|
||||
|
||||
if (mode == minimalEscapeAndQuote)
|
||||
*dst++ = C_DOUBLE_QUOTE;
|
||||
|
|
@ -846,11 +836,6 @@ 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;
|
||||
|
|
@ -996,22 +981,9 @@ AppendAVA(stringBuf* bufp, CERTAVA* ava, CertStrictnessLevel strict)
|
|||
}
|
||||
|
||||
nameLen = strlen(tagName);
|
||||
|
||||
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;
|
||||
}
|
||||
valueLen =
|
||||
(useHex ? avaValue->len : cert_RFC1485_GetRequiredLen(
|
||||
(char*)avaValue->data, avaValue->len, &mode));
|
||||
len = nameLen + valueLen + 2; /* Add 2 for '=' and trailing NUL */
|
||||
|
||||
maxName = nameLen;
|
||||
|
|
@ -1227,23 +1199,20 @@ avaToString(PLArenaPool* arena, CERTAVA* ava)
|
|||
if (!avaValue) {
|
||||
return buf;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
SECITEM_FreeItem(avaValue, PR_TRUE);
|
||||
|
|
@ -1521,7 +1490,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;
|
||||
|
|
@ -1533,7 +1502,7 @@ CERT_GetFirstEmailAddress(CERTCertificate* cert)
|
|||
** 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