mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 13:58:49 +00:00
[NSS] NSS_CMSContentInfo_SetContent: only modify cinfo if everything succeeds.
This commit is contained in:
@@ -156,37 +156,40 @@ SECStatus
|
|||||||
NSS_CMSContentInfo_SetContent(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo,
|
NSS_CMSContentInfo_SetContent(NSSCMSMessage *cmsg, NSSCMSContentInfo *cinfo,
|
||||||
SECOidTag type, void *ptr)
|
SECOidTag type, void *ptr)
|
||||||
{
|
{
|
||||||
SECStatus rv;
|
|
||||||
if (cinfo == NULL || cmsg == NULL) {
|
if (cinfo == NULL || cmsg == NULL) {
|
||||||
|
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||||
return SECFailure;
|
return SECFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
cinfo->contentTypeTag = SECOID_FindOIDByTag(type);
|
SECOidData *contentTypeTag = SECOID_FindOIDByTag(type);
|
||||||
if (cinfo->contentTypeTag == NULL) {
|
if (!contentTypeTag) {
|
||||||
return SECFailure;
|
return SECFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do not copy the oid, just create a reference */
|
SECItem contentType = { siBuffer, NULL, 0 };
|
||||||
rv = SECITEM_CopyItem(cmsg->poolp, &(cinfo->contentType), &(cinfo->contentTypeTag->oid));
|
SECStatus rv = SECITEM_CopyItem(cmsg->poolp, &contentType, &(contentTypeTag->oid));
|
||||||
if (rv != SECSuccess) {
|
if (rv != SECSuccess) {
|
||||||
return SECFailure;
|
return SECFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
cinfo->content.pointer = ptr;
|
SECItem *rawContent;
|
||||||
|
|
||||||
if (NSS_CMSType_IsData(type) && ptr) {
|
if (NSS_CMSType_IsData(type) && ptr) {
|
||||||
cinfo->rawContent = ptr;
|
rawContent = ptr;
|
||||||
} else {
|
} else {
|
||||||
/* as we always have some inner data,
|
/* as we always have some inner data,
|
||||||
* we need to set it to something, just to fool the encoder enough to work on it
|
* 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 */
|
* and get us into nss_cms_encoder_notify at that point */
|
||||||
cinfo->rawContent = SECITEM_AllocItem(cmsg->poolp, NULL, 1);
|
rawContent = SECITEM_AllocItem(cmsg->poolp, NULL, 1);
|
||||||
if (cinfo->rawContent == NULL) {
|
if (!rawContent) {
|
||||||
PORT_SetError(SEC_ERROR_NO_MEMORY);
|
|
||||||
return SECFailure;
|
return SECFailure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cinfo->contentType = contentType;
|
||||||
|
cinfo->content.pointer = ptr;
|
||||||
|
cinfo->contentTypeTag = contentTypeTag;
|
||||||
|
cinfo->rawContent = rawContent;
|
||||||
|
|
||||||
return SECSuccess;
|
return SECSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user