There are missing checks of its return value in 8 different spots.
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17154)
PKCS8_PRIV_KEY_INFO *p8inf = NULL;
const X509_ALGOR *alg = NULL;
BIO *in = ossl_bio_new_from_core_bio(ctx->provctx, cin);
- int ok = (asn1_d2i_read_bio(in, &mem) >= 0);
+ int ok = 0;
+ if (in == NULL)
+ return 0;
+
+ ok = (asn1_d2i_read_bio(in, &mem) >= 0);
BIO_free(in);
/* We return "empty handed". This is not an error. */
void *key = NULL;
int ok = 0;
+ if (in == NULL)
+ return 0;
+
if (BIO_read(in, hdr_buf, 16) != 16) {
ERR_raise(ERR_LIB_PEM, PEM_R_KEYBLOB_TOO_SHORT);
goto next;
unsigned char **data, long *len)
{
BIO *in = ossl_bio_new_from_core_bio(provctx, cin);
- int ok = (PEM_read_bio(in, pem_name, pem_header, data, len) > 0);
+ int ok;
+
+ if (in == NULL)
+ return 0;
+ ok = (PEM_read_bio(in, pem_name, pem_header, data, len) > 0);
BIO_free(in);
return ok;
void *key = NULL;
int ok = 0;
+ if (in == NULL)
+ return 0;
+
ctx->selection = selection;
if ((selection == 0
void *data, int len)
{
BIO *out = ossl_bio_new_from_core_bio(provctx, cout);
- int ret = BIO_write(out, data, len);
+ int ret;
+
+ if (out == NULL)
+ return 0;
+ ret = BIO_write(out, data, len);
BIO_free(out);
return ret;
EVP_PKEY *pkey, int ispub)
{
BIO *out = ossl_bio_new_from_core_bio(ctx->provctx, cout);
- int ret =
- ispub ? i2b_PublicKey_bio(out, pkey) : i2b_PrivateKey_bio(out, pkey);
+ int ret;
+
+ if (out == NULL)
+ return 0;
+ ret = ispub ? i2b_PublicKey_bio(out, pkey) : i2b_PrivateKey_bio(out, pkey);
BIO_free(out);
return ret;
EVP_PKEY *pkey)
{
BIO *out = NULL;
- int ret = 0;
+ int ret;
OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(ctx->provctx);
out = ossl_bio_new_from_core_bio(ctx->provctx, cout);
+ if (out == NULL)
+ return 0;
ret = i2b_PVK_bio_ex(out, pkey, ctx->pvk_encr_level,
ossl_pw_pvk_password, &ctx->pwdata, libctx, NULL);
BIO_free(out);
-
return ret;
}
{
BUF_MEM *mem = NULL;
BIO *in = ossl_bio_new_from_core_bio(provctx, cin);
- int ok = (asn1_d2i_read_bio(in, &mem) >= 0);
+ int ok;
+ if (in == NULL)
+ return 0;
+ ok = (asn1_d2i_read_bio(in, &mem) >= 0);
if (ok) {
*data = (unsigned char *)mem->data;
*len = (long)mem->length;