}
i = ASN1_item_i2d(x, &b, it);
- if (b == NULL) {
+ if (i < 0 || b == NULL) {
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
return NULL;
}
int i, j = 0, n, ret = 1;
n = ASN1_item_i2d(x, &b, it);
- if (b == NULL) {
+ if (n < 0 || b == NULL) {
ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
return 0;
}
alen = ASN1_item_i2d((ASN1_VALUE *)si->signedAttrs, &abuf,
ASN1_ITEM_rptr(CMS_Attributes_Sign));
- if (!abuf)
+ if (alen < 0 || abuf == NULL)
goto err;
if (EVP_DigestSignUpdate(mctx, abuf, alen) <= 0)
goto err;
}
seq->length = ASN1_item_i2d((ASN1_VALUE *)cap, &seq->data,
ASN1_ITEM_rptr(X509_ALGORS));
+ if (seq->length <= 0 || seq->data == NULL) {
+ ASN1_STRING_free(seq);
+ return 1;
+ }
if (!PKCS7_add_signed_attribute(si, NID_SMIMECapabilities,
V_ASN1_SEQUENCE, seq)) {
ASN1_STRING_free(seq);
alen = ASN1_item_i2d((ASN1_VALUE *)si->auth_attr, &abuf,
ASN1_ITEM_rptr(PKCS7_ATTR_SIGN));
- if (!abuf)
+ if (alen < 0 || abuf == NULL)
goto err;
if (EVP_DigestSignUpdate(mctx, abuf, alen) <= 0)
goto err;
alen = ASN1_item_i2d((ASN1_VALUE *)sk, &abuf,
ASN1_ITEM_rptr(PKCS7_ATTR_VERIFY));
- if (alen <= 0) {
+ if (alen <= 0 || abuf == NULL) {
ERR_raise(ERR_LIB_PKCS7, ERR_R_ASN1_LIB);
ret = -1;
goto err;