Merge branch 'nss-3.125-port'
This commit is contained in:
19 files changed
+117
-24
No files matched your search
@@ -8,6 +8,7 @@
|
||||
#include "secasn1.h"
|
||||
#include "secitem.h"
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include "secerr.h"
|
||||
#include "certi.h"
|
||||
|
||||
@@ -652,9 +653,18 @@ CERT_DecodeAVAValue(const SECItem *derAVAValue)
|
||||
}
|
||||
|
||||
if (convert != conv_none) {
|
||||
if (avaValue.len > UINT_MAX / 3) {
|
||||
PORT_DestroyCheapArena(&tmpArena);
|
||||
PORT_SetError(SEC_ERROR_INVALID_AVA);
|
||||
return NULL;
|
||||
}
|
||||
unsigned int utf8ValLen = avaValue.len * 3;
|
||||
unsigned char *utf8Val =
|
||||
(unsigned char *)PORT_ArenaZAlloc(&tmpArena.arena, utf8ValLen);
|
||||
if (!utf8Val) {
|
||||
PORT_DestroyCheapArena(&tmpArena);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (convert) {
|
||||
case conv_ucs4:
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* certhtml.c --- convert a cert to html
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "seccomon.h"
|
||||
#include "secitem.h"
|
||||
#include "sechash.h"
|
||||
@@ -14,6 +16,7 @@
|
||||
#include "secder.h"
|
||||
#include "prprf.h"
|
||||
#include "secport.h"
|
||||
#include "secerr.h"
|
||||
#include "secasn1.h"
|
||||
#include "pk11func.h"
|
||||
|
||||
@@ -32,6 +35,11 @@ CERT_Hexify(SECItem *i, int do_colon)
|
||||
return PORT_Strdup("00");
|
||||
}
|
||||
|
||||
if (i->len > UINT_MAX / 3) {
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rv = o = (char *)PORT_Alloc(i->len * 3);
|
||||
if (!rv)
|
||||
return rv;
|
||||
|
||||
@@ -696,6 +696,13 @@ SECKEY_ECParamsToKeySize(const SECItem *encodedParams)
|
||||
/* The encodedParams data contains 0x06 (SEC_ASN1_OBJECT_ID),
|
||||
* followed by the length of the curve oid and the curve oid.
|
||||
*/
|
||||
if (!encodedParams || !encodedParams->data ||
|
||||
encodedParams->len < 2 ||
|
||||
encodedParams->data[0] != SEC_ASN1_OBJECT_ID ||
|
||||
(unsigned)encodedParams->data[1] > encodedParams->len - 2) {
|
||||
PORT_SetError(SEC_ERROR_BAD_DER);
|
||||
return 0;
|
||||
}
|
||||
oid.len = encodedParams->data[1];
|
||||
oid.data = encodedParams->data + 2;
|
||||
if ((tag = SECOID_FindOIDTag(&oid)) == SEC_OID_UNKNOWN)
|
||||
|
||||
@@ -248,6 +248,11 @@ nss_cert_type_from_ck_attrib(CK_ATTRIBUTE_PTR attrib)
|
||||
/* default to PKIX */
|
||||
return NSSCertificateType_PKIX;
|
||||
}
|
||||
/* The token controls ulValueLen; reject any size that cannot hold a
|
||||
* full CK_CERTIFICATE_TYPE to avoid an out-of-bounds heap read. */
|
||||
if (attrib->ulValueLen != sizeof(CK_CERTIFICATE_TYPE)) {
|
||||
return NSSCertificateType_Unknown;
|
||||
}
|
||||
ckCertType = *((CK_ULONG *)attrib->pValue);
|
||||
switch (ckCertType) {
|
||||
case CKC_X_509:
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
* The format of the version string should be
|
||||
* "<major version>.<minor version>[.<patch level>[.<build number>]][ <ECC>][ <Beta>]"
|
||||
*/
|
||||
#define NSS_VERSION "3.90.12.0 (UXP)" _NSS_CUSTOMIZED
|
||||
#define NSS_VERSION "3.90.13.0 (UXP)" _NSS_CUSTOMIZED
|
||||
#define NSS_VMAJOR 3
|
||||
#define NSS_VMINOR 90
|
||||
#define NSS_VPATCH 12
|
||||
#define NSS_VPATCH 13
|
||||
#define NSS_VBUILD 0
|
||||
#define NSS_BETA PR_FALSE
|
||||
|
||||
|
||||
@@ -2269,11 +2269,20 @@ PK11_TraverseCertsForNicknameInSlot(SECItem *nickname, PK11SlotInfo *slot,
|
||||
NSSCertificate **certs;
|
||||
nssList *nameList = NULL;
|
||||
nssTokenSearchType tokenOnly = nssTokenSearchType_TokenOnly;
|
||||
if (!nickname || !nickname->data || nickname->len == 0) {
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return SECFailure;
|
||||
}
|
||||
token = PK11Slot_GetNSSToken(slot);
|
||||
if (!token || !nssToken_IsPresent(token)) {
|
||||
(void)nssToken_Destroy(token);
|
||||
return SECSuccess;
|
||||
}
|
||||
if (!nickname || !nickname->data || nickname->len == 0) {
|
||||
(void)nssToken_Destroy(token);
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return SECFailure;
|
||||
}
|
||||
if (nickname->data[nickname->len - 1] != '\0') {
|
||||
nick = nssUTF8_Create(NULL, nssStringType_UTF8String,
|
||||
nickname->data, nickname->len);
|
||||
|
||||
@@ -521,7 +521,7 @@ pk11_mergeSecretKey(PK11SlotInfo *targetSlot, PK11SlotInfo *sourceSlot,
|
||||
goto done;
|
||||
}
|
||||
input.len = blockSize;
|
||||
if (input.len == 0) {
|
||||
if (input.len == 0 || input.len > sizeof(testString)) {
|
||||
input.len = sizeof(testString);
|
||||
}
|
||||
while (targetKeyID != CK_INVALID_HANDLE) {
|
||||
|
||||
@@ -1214,6 +1214,12 @@ PK11_UnwrapPrivKey(PK11SlotInfo *slot, PK11SymKey *wrappingKey,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (usageCount < 0 ||
|
||||
usageCount > (int)(PR_ARRAY_SIZE(keyTemplate) - 8)) {
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ck_id = PK11_MakeIDFromPubKey(idValue);
|
||||
if (!ck_id) {
|
||||
return NULL;
|
||||
|
||||
@@ -371,7 +371,10 @@ PK11_GetWrapKey(PK11SlotInfo *slot, int wrap, CK_MECHANISM_TYPE type,
|
||||
CK_OBJECT_HANDLE keyHandle;
|
||||
|
||||
PK11_EnterSlotMonitor(slot);
|
||||
if (slot->series != series ||
|
||||
/* refKeys is a fixed-size array; bounds-check wrap to match
|
||||
* PK11_SetWrapKey. */
|
||||
if (wrap < 0 || (size_t)wrap >= PR_ARRAY_SIZE(slot->refKeys) ||
|
||||
slot->series != series ||
|
||||
slot->refKeys[wrap] == CK_INVALID_HANDLE) {
|
||||
PK11_ExitSlotMonitor(slot);
|
||||
return NULL;
|
||||
|
||||
@@ -162,6 +162,7 @@ pk11_FreeSlotListStatic(PK11SlotList *list)
|
||||
}
|
||||
list->lock = NULL;
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -820,6 +821,7 @@ pk11_InitSlotListStatic(PK11SlotList *list)
|
||||
{
|
||||
list->lock = PZ_NewLock(nssILockList);
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
}
|
||||
|
||||
/* initialize the system slotlists */
|
||||
|
||||
@@ -1105,7 +1105,7 @@ p12u_DigestClose(void *arg, PRBool removeFile)
|
||||
static int
|
||||
p12u_DigestRead(void *arg, unsigned char *buf, unsigned long len)
|
||||
{
|
||||
int toread = len;
|
||||
int toread;
|
||||
SEC_PKCS12DecoderContext *p12cxt = arg;
|
||||
|
||||
if (!buf || len == 0 || !p12cxt->buffer) {
|
||||
@@ -1113,10 +1113,16 @@ p12u_DigestRead(void *arg, unsigned char *buf, unsigned long len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((p12cxt->filesize - p12cxt->currentpos) < (long)len) {
|
||||
/* trying to read past the end of the buffer */
|
||||
toread = p12cxt->filesize - p12cxt->currentpos;
|
||||
/* Clamp `len` to the bytes left in the buffer. toread is positive here,
|
||||
* so the comparison stays unsigned and `len` cannot wrap. */
|
||||
toread = p12cxt->filesize - p12cxt->currentpos;
|
||||
if (toread <= 0) {
|
||||
return 0;
|
||||
}
|
||||
if (len < (unsigned long)toread) {
|
||||
toread = (int)len;
|
||||
}
|
||||
|
||||
memcpy(buf, (char *)p12cxt->buffer + p12cxt->currentpos, toread);
|
||||
p12cxt->currentpos += toread;
|
||||
return toread;
|
||||
@@ -1131,10 +1137,18 @@ p12u_DigestWrite(void *arg, unsigned char *buf, unsigned long len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (p12cxt->currentpos + (long)len > p12cxt->filesize) {
|
||||
p12cxt->filesize = p12cxt->currentpos + len;
|
||||
/* The buffer position counters are signed PRInt32. Reject any write
|
||||
* whose length would not fit so that `len` cannot overflow or wrap them
|
||||
* on LLP64 platforms where unsigned long is 32-bit (Win64). */
|
||||
if (len > (unsigned long)(PR_INT32_MAX - p12cxt->currentpos)) {
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (p12cxt->currentpos + (PRInt32)len > p12cxt->filesize) {
|
||||
p12cxt->filesize = p12cxt->currentpos + (PRInt32)len;
|
||||
} else {
|
||||
p12cxt->filesize += len;
|
||||
p12cxt->filesize += (PRInt32)len;
|
||||
}
|
||||
if (p12cxt->filesize > p12cxt->allocated) {
|
||||
void *newbuffer;
|
||||
@@ -1693,6 +1707,13 @@ sec_pkcs12_sanitize_nickname(PK11SlotInfo *slot, SECItem *nick)
|
||||
slotName[slotNameLen] = '\0';
|
||||
if (PORT_Strcmp(PK11_GetTokenName(slot), slotName) == 0) {
|
||||
delimitlen = PORT_Strlen(delimit + 1);
|
||||
if (delimitlen == 0) {
|
||||
/* Nickname was exactly "TokenName:" with nothing after the
|
||||
* prefix. Stripping it would yield an empty SECItem, which
|
||||
* is not a useful nickname; leave the original in place. */
|
||||
PORT_Free(slotName);
|
||||
return;
|
||||
}
|
||||
PORT_Memmove(nickname, delimit + 1, delimitlen + 1);
|
||||
nick->len = delimitlen;
|
||||
}
|
||||
|
||||
@@ -606,15 +606,20 @@ SEC_PKCS7DecryptContents(PLArenaPool *poolp,
|
||||
rv = PK11_CipherOp((PK11Context *)cx, dest->data, (int *)(&dest->len),
|
||||
(int)(src->len + 64), src->data, (int)src->len);
|
||||
PK11_DestroyContext((PK11Context *)cx, PR_TRUE);
|
||||
/* PK11_CipherOp may leave dest->len at 0; bail out before the padding
|
||||
* check so dest->len - 1 does not underflow. */
|
||||
if (rv != SECSuccess) {
|
||||
goto loser;
|
||||
}
|
||||
|
||||
bs = PK11_GetBlockSize(cryptoMechType, c_param);
|
||||
if (bs) {
|
||||
/* check for proper badding in block algorithms. this assumes
|
||||
* RC2 cbc or a DES cbc variant. and the padding is thus defined
|
||||
*/
|
||||
if (((int)dest->data[dest->len - 1] <= bs) &&
|
||||
((int)dest->data[dest->len - 1] > 0)) {
|
||||
dest->len -= (int)dest->data[dest->len - 1];
|
||||
/* Check for proper PKCS#7 padding: the last byte gives the number of
|
||||
* pad bytes, which must be in [1, bs]. */
|
||||
unsigned int pad = dest->data[dest->len - 1];
|
||||
if ((dest->len >= (unsigned int)bs) &&
|
||||
pad >= 1 && pad <= (unsigned int)bs) {
|
||||
dest->len -= pad;
|
||||
} else {
|
||||
rv = SECFailure;
|
||||
/* set an error ? */
|
||||
|
||||
@@ -773,6 +773,12 @@ sftk_ike1_appendix_b_prf(CK_SESSION_HANDLE hSession, const SFTKAttribute *inKey,
|
||||
}
|
||||
|
||||
outKeySize = PR_ROUNDUP(keySize, macSize);
|
||||
/* Reject if PR_ROUNDUP overflowed 32-bit unsigned arithmetic, which
|
||||
* would yield an undersized allocation for the loop below. */
|
||||
if (outKeySize < keySize) {
|
||||
crv = CKR_KEY_SIZE_RANGE;
|
||||
goto fail;
|
||||
}
|
||||
outKeyData = PORT_Alloc(outKeySize);
|
||||
if (outKeyData == NULL) {
|
||||
crv = CKR_HOST_MEMORY;
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
* The format of the version string should be
|
||||
* "<major version>.<minor version>[.<patch level>[.<build number>]][ <ECC>][ <Beta>]"
|
||||
*/
|
||||
#define SOFTOKEN_VERSION "3.90.12.0 (UXP)" SOFTOKEN_ECC_STRING
|
||||
#define SOFTOKEN_VERSION "3.90.13.0 (UXP)" SOFTOKEN_ECC_STRING
|
||||
#define SOFTOKEN_VMAJOR 3
|
||||
#define SOFTOKEN_VMINOR 90
|
||||
#define SOFTOKEN_VPATCH 12
|
||||
#define SOFTOKEN_VPATCH 13
|
||||
#define SOFTOKEN_VBUILD 0
|
||||
#define SOFTOKEN_BETA PR_FALSE
|
||||
|
||||
|
||||
@@ -722,7 +722,12 @@ ssl_CallCustomExtensionSenders(sslSocket *ss, sslBuffer *buf,
|
||||
if (hook->writer) {
|
||||
/* The writer writes directly into |buf|. Provide space that allows
|
||||
* for the existing extensions, any tail, plus type and length. */
|
||||
unsigned int space = buf->space - (buf->len + tail.len + 4);
|
||||
unsigned int used = buf->len + tail.len + 4;
|
||||
if (used > buf->space) {
|
||||
PORT_SetError(SEC_ERROR_APPLICATION_CALLBACK_ERROR);
|
||||
goto loser;
|
||||
}
|
||||
unsigned int space = buf->space - used;
|
||||
append = (*hook->writer)(ss->fd, message,
|
||||
buf->buf + buf->len + 4, &len, space,
|
||||
hook->writerArg);
|
||||
|
||||
@@ -164,6 +164,12 @@ ssl_BeginClientHandshake(sslSocket *ss)
|
||||
ss->sec.localCert = CERT_DupCertificate(sid->localCert);
|
||||
} else {
|
||||
ssl_UncacheSessionID(ss);
|
||||
if (ss->sec.ci.sid == sid) {
|
||||
/* sid aliases ss->sec.ci.sid (external cache); clear it so
|
||||
* the socket cannot hold a dangling pointer if the
|
||||
* ssl3_NewSessionID allocation below fails. */
|
||||
ss->sec.ci.sid = NULL;
|
||||
}
|
||||
ssl_FreeSID(sid);
|
||||
sid = NULL;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ tls13_HkdfExpandLabelGeneral(CK_MECHANISM_TYPE deriveMech, PK11SymKey *prk,
|
||||
PORT_Assert(keyp);
|
||||
if ((handshakeHashLen > 255) ||
|
||||
(handshakeHash == NULL && handshakeHashLen > 0) ||
|
||||
(labelLen + kLabelPrefixLen > 255)) {
|
||||
(labelLen > 255 - kLabelPrefixLen)) {
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
* The format of the version string should be
|
||||
* "<major version>.<minor version>[.<patch level>[.<build number>]][ <Beta>]"
|
||||
*/
|
||||
#define NSSUTIL_VERSION "3.90.12.0 (UXP)"
|
||||
#define NSSUTIL_VERSION "3.90.13.0 (UXP)"
|
||||
#define NSSUTIL_VMAJOR 3
|
||||
#define NSSUTIL_VMINOR 90
|
||||
#define NSSUTIL_VPATCH 12
|
||||
#define NSSUTIL_VPATCH 13
|
||||
#define NSSUTIL_VBUILD 0
|
||||
#define NSSUTIL_BETA PR_FALSE
|
||||
|
||||
|
||||
@@ -542,7 +542,7 @@ DecodeGroup(void* dest,
|
||||
rv = SECFailure;
|
||||
}
|
||||
if (SECSuccess == rv) {
|
||||
void* entriesData = (unsigned char*)entries + (unsigned long)(sizeof(void*) * (totalEntries + 1));
|
||||
void* entriesData = (unsigned char*)entries + sizeof(void*) * (totalEntries + 1);
|
||||
/* and fix the pointers in the array */
|
||||
PRUint32 entriesIndex = 0;
|
||||
for (entriesIndex = 0; entriesIndex < totalEntries; entriesIndex++) {
|
||||
|
||||
Reference in new issue
Block a user