File openssl-0005-BN_set_bit.patch of Package openssl-3

Description: Fix CWE-476 (NULL Pointer Dereference) in BN_set_bit
Issue: The pointer 'a' is dereferenced (a->top) before being passed to bn_wexpand, which includes a NULL check for 'a'. Accessing 'a' before this check is unsafe.

diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index 1234567..89abcde 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -791,4 +791,6 @@ int BN_set_bit(BIGNUM *a, int n)
     int i, j, k;
 
+    if (a == NULL)
+        return 0;
     if (n < 0)
         return 0;
openSUSE Build Service is sponsored by