Replace NSS with Pale Moon's

This commit is contained in:
wuggy 2026-06-29 21:29:25 +01:00
commit 8c2e376f94
2870 changed files with 1762232 additions and 1374220 deletions

View file

@ -156,37 +156,40 @@ SECStatus
NSS_CMSContentInfo_SetContent(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo,
SECOidTag type, void *ptr)
{
SECStatus rv;
if (cinfo == NULL || cmsg == NULL) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return SECFailure;
}
cinfo->contentTypeTag = SECOID_FindOIDByTag(type);
if (cinfo->contentTypeTag == NULL) {
SECOidData *contentTypeTag = SECOID_FindOIDByTag(type);
if (!contentTypeTag) {
return SECFailure;
}
/* do not copy the oid, just create a reference */
rv = SECITEM_CopyItem(cmsg->poolp, &(cinfo->contentType), &(cinfo->contentTypeTag->oid));
SECItem contentType = { siBuffer, NULL, 0 };
SECStatus rv = SECITEM_CopyItem(cmsg->poolp, &contentType, &(contentTypeTag->oid));
if (rv != SECSuccess) {
return SECFailure;
}
cinfo->content.pointer = ptr;
SECItem *rawContent;
if (NSS_CMSType_IsData(type) && ptr) {
cinfo->rawContent = ptr;
rawContent = ptr;
} else {
/* as we always have some inner data,
* we need to set it to something, just to fool the encoder enough to work on it
* and get us into nss_cms_encoder_notify at that point */
cinfo->rawContent = SECITEM_AllocItem(cmsg->poolp, NULL, 1);
if (cinfo->rawContent == NULL) {
PORT_SetError(SEC_ERROR_NO_MEMORY);
* we need to set it to something, just to fool the encoder enough to work on it
* and get us into nss_cms_encoder_notify at that point */
rawContent = SECITEM_AllocItem(cmsg->poolp, NULL, 1);
if (!rawContent) {
return SECFailure;
}
}
cinfo->contentType = contentType;
cinfo->content.pointer = ptr;
cinfo->contentTypeTag = contentTypeTag;
cinfo->rawContent = rawContent;
return SECSuccess;
}

View file

@ -84,7 +84,7 @@ nss_cms_decoder_notify(void *arg, PRBool before, void *dest, int depth)
p7dcx = (NSSCMSDecoderContext *)arg;
rootcinfo = &(p7dcx->cmsg->contentInfo);
/* XXX error handling: need to set p7dcx->error */
/* XXX error handling: need to set p7dcx->error */
#ifdef CMSDEBUG
fprintf(stderr, "%6.6s, dest = 0x%08x, depth = %d\n", before ? "before" : "after",
@ -529,8 +529,19 @@ nss_cms_decoder_work_data(NSSCMSDecoderContext *p7dcx,
SECItem *dataItem = &decoderData->data;
offset = dataItem->len;
/* Reject if accumulated size would exceed unsigned int storage. */
if (len > (unsigned long)(PR_UINT32_MAX - dataItem->len)) {
p7dcx->error = SEC_ERROR_INPUT_LEN;
goto loser;
}
if (dataItem->len + len > decoderData->totalBufferSize) {
int needLen = (dataItem->len + len) * 2;
/* Use size_t to avoid truncating the 64-bit sum to int.
* Double to amortize repeated reallocations across chunks. */
size_t needLen = (size_t)dataItem->len + len;
/* Only double if the result still fits in unsigned int. */
if (needLen <= PR_UINT32_MAX / 2) {
needLen *= 2;
}
dest = (unsigned char *)
PORT_ArenaAlloc(p7dcx->cmsg->poolp, needLen);
if (dest == NULL) {
@ -541,7 +552,7 @@ nss_cms_decoder_work_data(NSSCMSDecoderContext *p7dcx,
if (dataItem->len) {
PORT_Memcpy(dest, dataItem->data, dataItem->len);
}
decoderData->totalBufferSize = needLen;
decoderData->totalBufferSize = (unsigned int)needLen;
dataItem->data = dest;
}
@ -650,8 +661,7 @@ NSS_CMSDecoder_Update(NSSCMSDecoderContext *p7dcx, const char *buf,
* dealing with one of those replies. Supply the Sequence wrap
* as indefinite encoding (since we don't know the total length
* yet) */
static const char lbuf[2] =
{ SEC_ASN1_SEQUENCE | SEC_ASN1_CONSTRUCTED, 0x80 };
static const char lbuf[2] = { SEC_ASN1_SEQUENCE | SEC_ASN1_CONSTRUCTED, 0x80 };
rv = SEC_ASN1DecoderUpdate(p7dcx->dcx, lbuf, sizeof(lbuf));
if (rv != SECSuccess) {
goto loser;

View file

@ -476,7 +476,7 @@ NSS_CMSSignedData_SignerInfoCount(NSSCMSSignedData *sigd)
NSSCMSSignerInfo *
NSS_CMSSignedData_GetSignerInfo(NSSCMSSignedData *sigd, int i)
{
if (!sigd) {
if (!sigd || !sigd->signerInfos) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return NULL;
}
@ -619,7 +619,7 @@ NSS_CMSSignedData_ImportCerts(NSSCMSSignedData *sigd, CERTCertDBHandle *certdb,
rv = SECSuccess;
/* XXX CRL handling */
/* XXX CRL handling */
done:
if (sigd->signerInfos != NULL) {
@ -666,7 +666,7 @@ NSS_CMSSignedData_VerifySignerInfo(NSSCMSSignedData *sigd, int i,
SECOidTag oidTag;
SECStatus rv;
if (!sigd) {
if (!sigd || !sigd->signerInfos) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return SECFailure;
}

View file

@ -306,6 +306,10 @@ NSS_CMSContent_GetContentInfo(void *msg, SECOidTag type)
cinfo = &(c.genericData->contentInfo);
}
}
/* We are using a union as a form of 'safe casting'. This
* syntax confuses cppcheck, so tell it it's OK (and any human
* who happens along to verify any other scanner warnings) */
/* cppcheck-suppress returnDanglingLifetime */
return cinfo;
}

View file

@ -7,13 +7,6 @@ RELEASE_LIBS = $(TARGETS)
ifeq (,$(filter-out WIN%,$(OS_TARGET)))
# don't want the 32 in the shared library name
SHARED_LIBRARY = $(OBJDIR)/$(DLL_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
IMPORT_LIBRARY = $(OBJDIR)/$(IMPORT_LIB_PREFIX)$(LIBRARY_NAME)$(LIBRARY_VERSION)$(IMPORT_LIB_SUFFIX)
RES = $(OBJDIR)/smime.res
RESNAME = smime.rc
ifdef NS_USE_GCC
EXTRA_SHARED_LIBS += \
-L$(DIST)/lib \

View file

@ -17,7 +17,6 @@ PRIVATE_EXPORTS = \
$(NULL)
MODULE = nss
MAPFILE = $(OBJDIR)/smime.def
CSRCS = \
cmsarray.c \
@ -46,6 +45,7 @@ CSRCS = \
LIBRARY_NAME = smime
LIBRARY_VERSION = 3
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME).def
# This part of the code, including all sub-dirs, can be optimized for size
export ALLOW_OPT_CODE_SIZE = 1

View file

@ -285,3 +285,9 @@ SEC_PKCS12DecoderRenameCertNicknames;
;+ local:
;+ *;
;+};
;+NSS_3.89 { # NSS 3.89 release
;+ global:
NSS_CMSSignerInfo_GetDigestAlgTag;
;+ local:
;+ *;
;+};

View file

@ -509,7 +509,7 @@ smime_choose_cipher(CERTCertificate *scert, CERTCertificate **rcerts)
max = cipher_votes[mapi];
}
}
/* if no common cipher was found, chosen_cipher stays at the default */
/* if no common cipher was found, chosen_cipher stays at the default */
done:
if (poolp != NULL)