Bug 607058, crash [@ nss_cms_decoder_work_data], Patch contributed by timeless, r=kaie, r=nelson

git-svn-id: svn://10.0.0.236/trunk@261682 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
kaie%kuix.de 2010-12-21 21:58:56 +00:00
parent 7f5ff145d4
commit 48fe9178b4
2 changed files with 24 additions and 2 deletions

View File

@ -37,7 +37,7 @@
/*
* CMS decoding.
*
* $Id: cmsdecode.c,v 1.9 2006-08-05 01:19:23 julien.pierre.bugs%sun.com Exp $
* $Id: cmsdecode.c,v 1.10 2010-12-21 21:58:56 kaie%kuix.de Exp $
*/
#include "cmslocal.h"
@ -463,6 +463,11 @@ nss_cms_decoder_work_data(NSSCMSDecoderContext *p7dcx,
PORT_Assert ((data != NULL && len) || final);
cinfo = NSS_CMSContent_GetContentInfo(p7dcx->content.pointer, p7dcx->type);
if (!cinfo) {
/* The original programmer didn't expect this to happen */
p7dcx->error = SEC_ERROR_LIBRARY_FAILURE;
goto loser;
}
if (cinfo->ciphcx != NULL) {
/*

View File

@ -37,7 +37,7 @@
/*
* CMS encoding.
*
* $Id: cmsencode.c,v 1.6 2006-06-08 22:01:02 nelson%bolyard.com Exp $
* $Id: cmsencode.c,v 1.7 2010-12-21 21:58:56 kaie%kuix.de Exp $
*/
#include "cmslocal.h"
@ -425,6 +425,11 @@ nss_cms_encoder_work_data(NSSCMSEncoderContext *p7ecx, SECItem *dest,
/* we got data (either from the caller, or from a lower level encoder) */
cinfo = NSS_CMSContent_GetContentInfo(p7ecx->content.pointer, p7ecx->type);
if (!cinfo) {
/* The original programmer didn't expect this to happen */
p7ecx->error = SEC_ERROR_LIBRARY_FAILURE;
return SECFailure;
}
/* Update the running digest. */
if (len && cinfo->digcx != NULL)
@ -628,6 +633,12 @@ NSS_CMSEncoder_Update(NSSCMSEncoderContext *p7ecx, const char *data, unsigned lo
/* we are at innermost decoder */
/* find out about our inner content type - must be data */
cinfo = NSS_CMSContent_GetContentInfo(p7ecx->content.pointer, p7ecx->type);
if (!cinfo) {
/* The original programmer didn't expect this to happen */
p7ecx->error = SEC_ERROR_LIBRARY_FAILURE;
return SECFailure;
}
childtype = NSS_CMSContentInfo_GetContentTypeTag(cinfo);
if (childtype != SEC_OID_PKCS7_DATA)
return SECFailure;
@ -728,6 +739,12 @@ NSS_CMSEncoder_Finish(NSSCMSEncoderContext *p7ecx)
/* find out about our inner content type - must be data */
cinfo = NSS_CMSContent_GetContentInfo(p7ecx->content.pointer, p7ecx->type);
if (!cinfo) {
/* The original programmer didn't expect this to happen */
p7ecx->error = SEC_ERROR_LIBRARY_FAILURE;
rv = SECFailure;
goto loser;
}
childtype = NSS_CMSContentInfo_GetContentTypeTag(cinfo);
if (childtype == SEC_OID_PKCS7_DATA && cinfo->content.data == NULL) {
SEC_ASN1EncoderClearTakeFromBuf(p7ecx->ecx);