From bc9f8a8100e330b7791effd11076dfc09d3c5d04 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Fri, 9 Feb 2024 18:44:36 +0000 Subject: [PATCH] genprotimg: Fix out-of-disk space handling Convert the assertion to a GError since an out-of-disk-space situation is a valid situation that should be handled. ERROR:utils/crypto.c:1843:__encrypt_decrypt_bio: assertion failed: (num_bytes_written == out_len) Bail out! ERROR:utils/crypto.c:1843:__encrypt_decrypt_bio: assertion failed: (num_bytes_written == out_len) Reviewed-by: Steffen Eiden Signed-off-by: Marc Hartmayer Signed-off-by: Steffen Eiden --- genprotimg/src/utils/crypto.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/genprotimg/src/utils/crypto.c b/genprotimg/src/utils/crypto.c index 86565b99..3636cadb 100644 --- a/genprotimg/src/utils/crypto.c +++ b/genprotimg/src/utils/crypto.c @@ -1826,14 +1826,12 @@ static gint __encrypt_decrypt_bio(const struct cipher_parms *parms, BIO *b_in, g_assert(out_len >= 0); num_bytes_written = BIO_write(b_out, out_buf, out_len); - if (num_bytes_written < 0) { + if (num_bytes_written != out_len) { g_set_error(err, PV_CRYPTO_ERROR, PV_CRYPTO_ERROR_INTERNAL, _("Failed to write")); return -1; } - g_assert(num_bytes_written == out_len); - tmp_size_out += (guint)num_bytes_written; /* Set new tweak value. Please keep in mind that the