Bug 1088969 - Upgrade Mozilla 36 to use NSS 3.18 - NSS_3_18_BETA2

This commit is contained in:
Kai Engert 2014-11-17 14:57:45 +01:00
parent bf551bc75c
commit 63ef926a61
6 changed files with 1003 additions and 758 deletions

View File

@ -1 +1 @@
NSS_3_18_BETA1
NSS_3_18_BETA2

View File

@ -10,3 +10,4 @@
*/
#error "Do not include this header file."

View File

@ -183,7 +183,16 @@ nss_builtins_FindObjectsInit
NSSArena *arena;
NSSCKMDFindObjects *rv = (NSSCKMDFindObjects *)NULL;
struct builtinsFOStr *fo = (struct builtinsFOStr *)NULL;
builtinsInternalObject **temp = (builtinsInternalObject **)NULL;
/*
* 99% of the time we get 0 or 1 matches. So we start with a small
* stack-allocated array to hold the matches and switch to a heap-allocated
* array later if the number of matches exceeds STACK_BUF_LENGTH.
*/
#define STACK_BUF_LENGTH 1
builtinsInternalObject *stackTemp[STACK_BUF_LENGTH];
builtinsInternalObject **temp = stackTemp;
PRBool tempIsHeapAllocated = PR_FALSE;
PRUint32 i;
arena = NSSArena_Create();
@ -211,17 +220,24 @@ nss_builtins_FindObjectsInit
rv->Next = builtins_mdFindObjects_Next;
rv->null = (void *)NULL;
temp = nss_ZNEWARRAY((NSSArena *)NULL, builtinsInternalObject *,
nss_builtins_nObjects);
if( (builtinsInternalObject **)NULL == temp ) {
*pError = CKR_HOST_MEMORY;
goto loser;
}
for( i = 0; i < nss_builtins_nObjects; i++ ) {
builtinsInternalObject *o = (builtinsInternalObject *)&nss_builtins_data[i];
if( CK_TRUE == builtins_match(pTemplate, ulAttributeCount, o) ) {
if( fo->n == STACK_BUF_LENGTH ) {
/* Switch from the small stack array to a heap-allocated array large
* enough to handle matches in all remaining cases. */
temp = nss_ZNEWARRAY((NSSArena *)NULL, builtinsInternalObject *,
fo->n + nss_builtins_nObjects - i);
if( (builtinsInternalObject **)NULL == temp ) {
*pError = CKR_HOST_MEMORY;
goto loser;
}
tempIsHeapAllocated = PR_TRUE;
(void)nsslibc_memcpy(temp, stackTemp,
sizeof(builtinsInternalObject *) * fo->n);
}
temp[ fo->n ] = o;
fo->n++;
}
@ -234,13 +250,17 @@ nss_builtins_FindObjectsInit
}
(void)nsslibc_memcpy(fo->objs, temp, sizeof(builtinsInternalObject *) * fo->n);
nss_ZFreeIf(temp);
temp = (builtinsInternalObject **)NULL;
if (tempIsHeapAllocated) {
nss_ZFreeIf(temp);
temp = (builtinsInternalObject **)NULL;
}
return rv;
loser:
nss_ZFreeIf(temp);
if (tempIsHeapAllocated) {
nss_ZFreeIf(temp);
}
nss_ZFreeIf(fo);
nss_ZFreeIf(rv);
if ((NSSArena *)NULL != arena) {

File diff suppressed because it is too large Load Diff

View File

@ -45,8 +45,8 @@
* of the comment in the CK_VERSION type definition.
*/
#define NSS_BUILTINS_LIBRARY_VERSION_MAJOR 2
#define NSS_BUILTINS_LIBRARY_VERSION_MINOR 1
#define NSS_BUILTINS_LIBRARY_VERSION "2.1"
#define NSS_BUILTINS_LIBRARY_VERSION_MINOR 2
#define NSS_BUILTINS_LIBRARY_VERSION "2.2"
/* These version numbers detail the semantic changes to the ckfw engine. */
#define NSS_BUILTINS_HARDWARE_VERSION_MAJOR 1

View File

@ -16,55 +16,110 @@
*/
static unsigned char* definite_length_decoder(const unsigned char *buf,
const unsigned int length,
unsigned int *data_length,
const unsigned int buf_length,
unsigned int *out_data_length,
PRBool includeTag)
{
unsigned char tag;
unsigned int used_length= 0;
unsigned int data_len;
unsigned int used_length = 0;
unsigned int data_length = 0;
unsigned char length_field_len = 0;
unsigned char byte;
unsigned int i;
if (used_length >= length)
if (used_length >= buf_length)
{
/* Tag field was not found! */
return NULL;
}
tag = buf[used_length++];
/* blow out when we come to the end */
if (tag == 0)
{
/* End-of-contents octects should not be present in DER because
DER doesn't use the indefinite length form. */
return NULL;
}
if (used_length >= length)
if ((tag & 0x1F) == 0x1F)
{
/* High tag number (a tag number > 30) is not supported */
return NULL;
}
data_len = buf[used_length++];
if (data_len&0x80)
if (used_length >= buf_length)
{
int len_count = data_len & 0x7f;
/* Length field was not found! */
return NULL;
}
byte = buf[used_length++];
data_len = 0;
while (len_count-- > 0)
if (!(byte & 0x80))
{
/* Short form: The high bit is not set. */
data_length = byte; /* clarity; we're returning a 32-bit int. */
}
else
{
/* Long form. Extract the field length */
length_field_len = byte & 0x7F;
if (length_field_len == 0)
{
if (used_length >= length)
/* DER doesn't use the indefinite length form. */
return NULL;
}
if (length_field_len > sizeof(data_length))
{
/* We don't support an extended length field longer than
4 bytes (2^32) */
return NULL;
}
if (length_field_len > (buf_length - used_length))
{
/* Extended length field was not found */
return NULL;
}
/* Iterate across the extended length field */
for (i = 0; i < length_field_len; i++)
{
byte = buf[used_length++];
data_length = (data_length << 8) | byte;
if (i == 0)
{
return NULL;
PRBool too_long = PR_FALSE;
if (length_field_len == 1)
{
too_long = ((byte & 0x80) == 0); /* Short form suffices */
}
else
{
too_long = (byte == 0); /* This zero byte can be omitted */
}
if (too_long)
{
/* The length is longer than needed. */
return NULL;
}
}
data_len = (data_len << 8) | buf[used_length++];
}
}
if (data_len > (length-used_length) )
if (data_length > (buf_length - used_length))
{
/* The decoded length exceeds the available buffer */
return NULL;
}
if (includeTag) data_len += used_length;
*data_length = data_len;
if (includeTag)
{
data_length += used_length;
}
*out_data_length = data_length;
return ((unsigned char*)buf + (includeTag ? 0 : used_length));
}