# A patch for Bug #61124

- Thread: https://externals.io/message/57905
- Original archive: https://news-web.php.net/php.internals/57905
- Started by Kiyoto Tamura on 2012-02-19T09:12:22+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #57905 — Kiyoto Tamura — 2012-02-19T09:12:22+00:00

URL: https://externals.io/message/57905#57905

I propose the following patch to prevent segfault for openssl_decrypt as detailed in https://bugs.php.net/bug.php?id=61124

Index: ext/openssl/openssl.c
===================================================================
--- ext/openssl/openssl.c       (revision 323312)
+++ ext/openssl/openssl.c       (working copy)
@@ -4801,6 +4801,10 @@
                base64_str = (char*)php_base64_decode((unsigned char*)data, data_len, &base64_str_len);
                data_len = base64_str_len;
                data = base64_str;
+               if (data == NULL) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to decode the base64 input");
+                       RETURN_FALSE;
+               }
        }
 
        keylen = EVP_CIPHER_key_length(cipher_type);

Feedback is appreciated. Thanks!

Kiyoto
