]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.0' into PHP-7.1
authorStanislav Malyshev <stas@php.net>
Thu, 13 Oct 2016 06:26:15 +0000 (23:26 -0700)
committerStanislav Malyshev <stas@php.net>
Thu, 13 Oct 2016 06:26:15 +0000 (23:26 -0700)
* PHP-7.0:
  Fix outlen for openssl function
  Syncronize with 5.6 - __toString should return ""
  Fix potential overflows in php_pcre_replace_impl

1  2 
Zend/zend_alloc.c
Zend/zend_multiply.h
ext/openssl/openssl.c
ext/pcre/php_pcre.c
ext/spl/spl_iterators.c

Simple merge
Simple merge
index dc16499950008684d1914975f44eabc6fd53afac,6bf1d6b25f20530f9d91ea17ca9123d86abafb4a..58053d21735cea08263a0e93fb79e4534c976ec1
@@@ -6336,18 -5383,18 +6336,18 @@@ PHP_FUNCTION(openssl_encrypt
  PHP_FUNCTION(openssl_decrypt)
  {
        zend_long options = 0;
 -      char *data, *method, *password, *iv = "";
 -      size_t data_len, method_len, password_len, iv_len = 0;
 +      char *data, *method, *password, *iv = "", *tag = NULL, *aad = "";
 +      size_t data_len, method_len, password_len, iv_len = 0, tag_len = 0, aad_len = 0;
        const EVP_CIPHER *cipher_type;
 -      EVP_CIPHER_CTX cipher_ctx;
 -      int i, keylen;
 -      size_t outlen;
 +      EVP_CIPHER_CTX *cipher_ctx;
 +      struct php_openssl_cipher_mode mode;
-       int outlen, i = 0;
++      int i = 0, outlen;
        zend_string *outbuf;
 -      unsigned char *key;
        zend_string *base64_str = NULL;
 -      zend_bool free_iv;
 +      zend_bool free_iv = 0, free_password = 0;
  
 -      if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|ls", &data, &data_len, &method, &method_len, &password, &password_len, &options, &iv, &iv_len) == FAILURE) {
 +      if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|lsss", &data, &data_len, &method, &method_len,
 +                                      &password, &password_len, &options, &iv, &iv_len, &tag, &tag_len, &aad, &aad_len) == FAILURE) {
                return;
        }
  
                RETURN_FALSE;
        }
  
 +      cipher_ctx = EVP_CIPHER_CTX_new();
 +      if (!cipher_ctx) {
 +              php_error_docref(NULL, E_WARNING, "Failed to create cipher context");
 +              RETURN_FALSE;
 +      }
 +
 +      php_openssl_load_cipher_mode(&mode, cipher_type);
 +
        if (!(options & OPENSSL_RAW_DATA)) {
-               base64_str = php_base64_decode_ex((unsigned char*)data, (int)data_len, 1);
+               base64_str = php_base64_decode((unsigned char*)data, data_len);
                if (!base64_str) {
                        php_error_docref(NULL, E_WARNING, "Failed to base64 decode the input");
 +                      EVP_CIPHER_CTX_free(cipher_ctx);
                        RETURN_FALSE;
                }
                data_len = ZSTR_LEN(base64_str);
Simple merge
Simple merge