[openssl/openssl] a21fdf: Fix crash in EVP_MD_CTX_copy_ex on inconsistent co...

"'Ingo Franzki' via openssl-commits" <[email protected]> Tue, 07 Jul 2026 21:18:33 -0700
Newsgroups gmane.comp.encryption.openssl.cvs
Message-ID <openssl/openssl/push/refs/heads/master/[email protected]>
  Branch: refs/heads/master
  Home:   https://github.com/openssl/openssl
  Commit: a21fdfc89aa07c62ca642bc729ef0c42e7cb0f7d
      https://github.com/openssl/openssl/commit/a21fdfc89aa07c62ca642bc729ef0c42e7cb0f7d
  Author: Ingo Franzki <[email protected]>
  Date:   2026-07-08 (Wed, 08 Jul 2026)

  Changed paths:
    M crypto/evp/digest.c

  Log Message:
  -----------
  Fix crash in EVP_MD_CTX_copy_ex on inconsistent context

EVP_MD_CTX_copy_ex() might crash on an NULL pointer access when an
inconsistent context is copied. This happens when a context is copied
where digest is set but algctx is NULL, i.e. due to an incomplete
initialization.

The copyctx shortcut for cases where the in and out contexts use the
exact same digest call the copyctx function attempting to copy
the algctx, but it does not check if algctx is NULL on the in or out
contexts.

Fix this by only taking the copyctx shortcut if algctx is non-NULL on
both, in and out. Otherwise use the full copy path which will only
duplicate the algctx if it is non-NULL.

Closes: https://github.com/openssl/openssl/issues/31831

Signed-off-by: Ingo Franzki <[email protected]>

Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/31867)



To unsubscribe from these emails, change your notification settings at https://github.com/openssl/openssl/settings/notifications

-- 
You received this message because you are subscribed to the Google Groups "openssl-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/a/openssl.org/d/msgid/openssl-commits/openssl/openssl/push/refs/heads/master/46040a-a21fdf%40github.com.