Skip to content

Commit

Permalink
Bug 1308866 - Make cert test suite run with ASan+LSan+UBSan r=franziskus
Browse files Browse the repository at this point in the history
Differential Revision: https://nss-dev.phacility.com/D78

--HG--
extra : amend_source : e740584ad8b6f308098db21514bc0e38709c6c95
  • Loading branch information
Tim Taubert committed Oct 12, 2016
1 parent 1044f92 commit 03788a2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
13 changes: 9 additions & 4 deletions cmd/certutil/certext.c
Expand Up @@ -1240,10 +1240,15 @@ AddCrlDistPoint(void *extHandle)
}
}

crlDistPoints->distPoints =
PORT_ArenaGrow(arena, crlDistPoints->distPoints,
sizeof(*crlDistPoints->distPoints) * count,
sizeof(*crlDistPoints->distPoints) * (count + 1));
if (crlDistPoints->distPoints) {
crlDistPoints->distPoints =
PORT_ArenaGrow(arena, crlDistPoints->distPoints,
sizeof(*crlDistPoints->distPoints) * count,
sizeof(*crlDistPoints->distPoints) * (count + 1));
} else {
crlDistPoints->distPoints =
PORT_ArenaZAlloc(arena, sizeof(*crlDistPoints->distPoints) * (count + 1));
}
if (crlDistPoints->distPoints == NULL) {
GEN_BREAK(SECFailure);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/certdb/crl.c
Expand Up @@ -1958,10 +1958,11 @@ DPCache_SelectCRL(CRLDPCache* cache)
qsort(cache->crls, cache->ncrls, sizeof(CachedCrl*), SortImperfectCRLs);
return SECSuccess;
}
/* all CRLs are good, sort them by thisUpdate */
qsort(cache->crls, cache->ncrls, sizeof(CachedCrl*), SortCRLsByThisUpdate);

if (cache->ncrls) {
/* all CRLs are good, sort them by thisUpdate */
qsort(cache->crls, cache->ncrls, sizeof(CachedCrl*), SortCRLsByThisUpdate);

/* pick the newest CRL */
selected = cache->crls[cache->ncrls - 1];

Expand Down
3 changes: 2 additions & 1 deletion lib/freebl/alg2268.c
Expand Up @@ -10,6 +10,7 @@
#endif

#include "blapi.h"
#include "blapii.h"
#include "secerr.h"
#ifdef XP_UNIX_XXX
#include <stddef.h> /* for ptrdiff_t */
Expand Down Expand Up @@ -418,7 +419,7 @@ rc2_EncryptCBC(RC2Context *cx, unsigned char *output,
return SECSuccess;
}

static SECStatus
static SECStatus NO_SANITIZE_ALIGNMENT
rc2_DecryptCBC(RC2Context *cx, unsigned char *output,
const unsigned char *input, unsigned int inputLen)
{
Expand Down
4 changes: 3 additions & 1 deletion lib/softoken/legacydb/lgattr.c
Expand Up @@ -1411,7 +1411,9 @@ lg_cmpAttribute(LGObjectCache *obj, const CK_ATTRIBUTE *attribute)
/* get the attribute */
crv = lg_GetSingleAttribute(obj, &testAttr);
/* if the attribute was read OK, compare it */
if ((crv != CKR_OK) || (attribute->ulValueLen != testAttr.ulValueLen) ||
if ((crv != CKR_OK) ||
(attribute->pValue == NULL) ||
(attribute->ulValueLen != testAttr.ulValueLen) ||
(PORT_Memcmp(attribute->pValue, testAttr.pValue, testAttr.ulValueLen) != 0)) {
/* something didn't match, this isn't the object we are looking for */
match = PR_FALSE;
Expand Down
6 changes: 5 additions & 1 deletion lib/softoken/legacydb/pcertdb.c
Expand Up @@ -2172,7 +2172,11 @@ EncodeDBSubjectEntry(certDBEntrySubject *entry, PLArenaPool *arena,
buf[4] = 0;
buf[5] = 0;

PORT_Memcpy(&buf[DB_SUBJECT_ENTRY_HEADER_LEN], entry->nickname, nnlen);
PORT_Assert(DB_SUBJECT_ENTRY_HEADER_LEN == 6);

if (entry->nickname) {
PORT_Memcpy(&buf[DB_SUBJECT_ENTRY_HEADER_LEN], entry->nickname, nnlen);
}
tmpbuf = &buf[keyidoff];
for (i = 0; i < ncerts; i++) {
tmpbuf[0] = (PRUint8)(certKeys[i].len >> 8);
Expand Down

0 comments on commit 03788a2

Please sign in to comment.