зеркало из https://github.com/mozilla/gecko-dev.git
Allocate memory when setting digest vale. Checkin approved by relyea
This commit is contained in:
Родитель
3eb643cc9d
Коммит
cefe60de72
|
@ -34,7 +34,7 @@
|
|||
/*
|
||||
* CMS signedData methods.
|
||||
*
|
||||
* $Id: cmssigdata.c,v 1.11 2001/01/07 08:13:07 nelsonb%netscape.com Exp $
|
||||
* $Id: cmssigdata.c,v 1.12 2001/11/02 00:03:32 ddrinan%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#include "cmslocal.h"
|
||||
|
@ -737,18 +737,31 @@ NSS_CMSSignedData_SetDigestValue(NSSCMSSignedData *sigd,
|
|||
SECItem *digest = NULL;
|
||||
PLArenaPool *poolp;
|
||||
void *mark;
|
||||
int n;
|
||||
int n, cnt;
|
||||
|
||||
poolp = sigd->cmsg->poolp;
|
||||
|
||||
mark = PORT_ArenaMark(poolp);
|
||||
|
||||
|
||||
if (digestdata) {
|
||||
digest = (SECItem *) PORT_ArenaZAlloc(poolp,sizeof(SECItem));
|
||||
|
||||
/* copy digestdata item to arena (in case we have it and are not only making room) */
|
||||
if (SECITEM_CopyItem(poolp, digest, digestdata) != SECSuccess)
|
||||
goto loser;
|
||||
}
|
||||
|
||||
/* now allocate one (same size as digestAlgorithms) */
|
||||
if (sigd->digests == NULL) {
|
||||
cnt = NSS_CMSArray_Count((void **)sigd->digestAlgorithms);
|
||||
sigd->digests = PORT_ArenaZAlloc(sigd->cmsg->poolp, (cnt + 1) * sizeof(SECItem *));
|
||||
if (sigd->digests == NULL) {
|
||||
PORT_SetError(SEC_ERROR_NO_MEMORY);
|
||||
return SECFailure;
|
||||
}
|
||||
}
|
||||
|
||||
n = -1;
|
||||
if (sigd->digestAlgorithms != NULL)
|
||||
n = NSS_CMSAlgArray_GetIndexByAlgTag(sigd->digestAlgorithms, digestalgtag);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
/*
|
||||
* CMS miscellaneous utility functions.
|
||||
*
|
||||
* $Id: cmsutil.c,v 1.6 2001/09/20 22:15:32 relyea%netscape.com Exp $
|
||||
* $Id: cmsutil.c,v 1.7 2001/11/02 00:03:32 ddrinan%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#include "nssrenam.h"
|
||||
|
@ -380,7 +380,7 @@ NSS_CMSDEREncode(NSSCMSMessage *cmsg, SECItem *input, SECItem *derOut,
|
|||
return SECFailure;
|
||||
}
|
||||
if (input) {
|
||||
rv = NSS_CMSEncoder_Update(ecx, (char *)input->data, input->len);
|
||||
rv = NSS_CMSEncoder_Update(ecx, (const char*)input->data, input->len);
|
||||
if (rv) {
|
||||
PORT_SetError(SEC_ERROR_BAD_DATA);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче