mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
genprotimg: check return value of BIO_reset
Add missing return value checks for BIO_reset. Unfortunately, the OpenSSL documentation says: "BIO_reset() normally returns 1 for success and 0 or -1 for failure. File BIOs are an exception, they return 0 for success and -1 for failure." Github-ID: https://github.com/ibm-s390-linux/s390-tools/issues/112 Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
71a667fbf0
commit
d90344a2d5
@@ -440,10 +440,14 @@ static int check_signature_algo_match(const EVP_PKEY *pkey, const X509 *subject,
|
||||
static X509_CRL *load_crl_from_bio(BIO *bio)
|
||||
{
|
||||
g_autoptr(X509_CRL) crl = PEM_read_bio_X509_CRL(bio, NULL, 0, NULL);
|
||||
gint rc;
|
||||
|
||||
if (crl)
|
||||
return g_steal_pointer(&crl);
|
||||
ERR_clear_error();
|
||||
BIO_reset(bio);
|
||||
rc = BIO_reset(bio);
|
||||
if (rc != 1 || (rc != 0 && BIO_method_type(bio) == BIO_TYPE_FILE))
|
||||
return NULL;
|
||||
|
||||
/* maybe the CRL is stored in DER format */
|
||||
crl = d2i_X509_CRL_bio(bio, NULL);
|
||||
@@ -514,6 +518,7 @@ X509 *load_cert_from_file(const char *path, GError **err)
|
||||
{
|
||||
g_autoptr(BIO) bio = bio_read_from_file(path);
|
||||
g_autoptr(X509) cert = NULL;
|
||||
gint rc;
|
||||
|
||||
if (!bio) {
|
||||
g_set_error(err, PV_CRYPTO_ERROR,
|
||||
@@ -526,7 +531,12 @@ X509 *load_cert_from_file(const char *path, GError **err)
|
||||
if (cert)
|
||||
return g_steal_pointer(&cert);
|
||||
ERR_clear_error();
|
||||
BIO_reset(bio);
|
||||
rc = BIO_reset(bio);
|
||||
if (rc != 1 || (rc != 0 && BIO_method_type(bio) == BIO_TYPE_FILE)) {
|
||||
g_set_error(err, PV_CRYPTO_ERROR, PV_CRYPTO_ERROR_READ_CERTIFICATE,
|
||||
_("unable to load certificate: '%s'"), path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* maybe the certificate is stored in DER format */
|
||||
cert = d2i_X509_bio(bio, NULL);
|
||||
|
||||
Reference in New Issue
Block a user