From 3822a71b2eecc16ecc64696f0b3b320845e65b58 Mon Sep 17 00:00:00 2001 From: Theo Buehler Date: Mon, 25 Mar 2024 17:36:13 +1100 Subject: Backport jca's byname fix --- patches/byname.patch | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 patches/byname.patch (limited to 'patches') diff --git a/patches/byname.patch b/patches/byname.patch new file mode 100644 index 0000000..ee1cd81 --- /dev/null +++ b/patches/byname.patch @@ -0,0 +1,65 @@ +Backport fix for behavior change for EVP_get_{cipher,digest}byname() +https://github.com/openbsd/src/commit/ace1aaedae16f4098783ed4a8c5602142650126c + +--- crypto/evp/evp_names.c.orig Mon Mar 25 17:27:41 2024 ++++ crypto/evp/evp_names.c Mon Mar 25 17:30:27 2024 +@@ -1852,6 +1852,9 @@ EVP_get_cipherbyname(const char *name) + if (!OPENSSL_init_crypto(0, NULL)) + return NULL; + ++ if (name == NULL) ++ return NULL; ++ + if ((cipher = bsearch(name, cipher_names, N_CIPHER_NAMES, + sizeof(*cipher), cipher_cmp)) == NULL) + return NULL; +@@ -1871,6 +1874,9 @@ EVP_get_digestbyname(const char *name) + const struct digest_name *digest; + + if (!OPENSSL_init_crypto(0, NULL)) ++ return NULL; ++ ++ if (name == NULL) + return NULL; + + if ((digest = bsearch(name, digest_names, N_DIGEST_NAMES, +--- tests/evp_test.c.orig Mon Mar 25 17:27:41 2024 ++++ tests/evp_test.c Mon Mar 25 17:31:32 2024 +@@ -737,6 +737,28 @@ obj_name_do_all_test(void) + return failure; + } + ++static int ++evp_get_cipherbyname_test(void) ++{ ++ int failure = 0; ++ ++ /* Should handle NULL gracefully */ ++ failure |= EVP_get_cipherbyname(NULL) != NULL; ++ ++ return failure; ++} ++ ++static int ++evp_get_digestbyname_test(void) ++{ ++ int failure = 0; ++ ++ /* Should handle NULL gracefully */ ++ failure |= EVP_get_digestbyname(NULL) != NULL; ++ ++ return failure; ++} ++ + int + main(int argc, char **argv) + { +@@ -748,6 +770,8 @@ main(int argc, char **argv) + failed |= evp_do_all_test(); + failed |= evp_aliases_test(); + failed |= obj_name_do_all_test(); ++ failed |= evp_get_cipherbyname_test(); ++ failed |= evp_get_digestbyname_test(); + + OPENSSL_cleanup(); + -- cgit v1.2.3-55-g6feb