summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-01-28 17:34:20 +0300
committerDmitry Stogov <dmitry@zend.com>2015-01-28 17:34:20 +0300
commit994d4350d3e4bb1bbf384ab04e84517b8ac4c250 (patch)
tree521f5f75a3828f1684b00ba12b2e42bdf2e882a9
parenteef80c583762d1e98d177cdbb27e3a8a6b0c4539 (diff)
parent4d1693744996f78618da768114a2b225fe4fd503 (diff)
downloadphp-git-994d4350d3e4bb1bbf384ab04e84517b8ac4c250.tar.gz
Merge branch 'master' into foreach
* master: fix unportable dereferencing fbird_close if connection_id omitted, the last opened link is assumed , so it was already closed Fixed #68868 (Segfault in clean_non_persistent_constants() in SugarCRM 6.5.20)
-rw-r--r--NEWS2
-rw-r--r--ext/interbase/tests/ibase_trans_001.phpt4
-rw-r--r--ext/openssl/openssl.c10
-rw-r--r--ext/session/session.c21
-rw-r--r--ext/session/tests/session_regenerate_id_fastshutdown.phpt14
5 files changed, 41 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index 9d669be89a..417c2ac3ee 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@
. Update the MIME type list from the one shipped by Apache HTTPD. (Adam)
- Core:
+ . Fixed #68868 (Segfault in clean_non_persistent_constants() in SugarCRM
+ 6.5.20). (Laruence)
. Fixed bug #68104 (Segfault while pre-evaluating a disabled function).
(Laruence)
. Fixed bug #68252 (segfault in Zend/zend_hash.c in function
diff --git a/ext/interbase/tests/ibase_trans_001.phpt b/ext/interbase/tests/ibase_trans_001.phpt
index cceb60e9a1..d8b7c81a1b 100644
--- a/ext/interbase/tests/ibase_trans_001.phpt
+++ b/ext/interbase/tests/ibase_trans_001.phpt
@@ -18,4 +18,6 @@ var_dump(ibase_close($x));
resource(%d) of type (Firebird/InterBase transaction)
resource(%d) of type (Firebird/InterBase transaction)
bool(true)
-bool(true)
+
+Warning: ibase_close(): supplied resource is not a valid Firebird/InterBase link resource in %s on line %d
+bool(false)
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 74d9f0c11f..1a4c1c3052 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -5067,7 +5067,7 @@ PHP_FUNCTION(openssl_digest)
}
/* }}} */
-static zend_bool php_openssl_validate_iv(char **piv, int *piv_len, int iv_required_len)
+static zend_bool php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_required_len)
{
char *iv_new;
@@ -5078,7 +5078,7 @@ static zend_bool php_openssl_validate_iv(char **piv, int *piv_len, int iv_requir
iv_new = ecalloc(1, iv_required_len + 1);
- if (*piv_len <= 0) {
+ if (*piv_len == 0) {
/* BC behavior */
*piv_len = iv_required_len;
*piv = iv_new;
@@ -5134,10 +5134,10 @@ PHP_FUNCTION(openssl_encrypt)
}
max_iv_len = EVP_CIPHER_iv_length(cipher_type);
- if (iv_len <= 0 && max_iv_len > 0) {
+ if (iv_len == 0 && max_iv_len > 0) {
php_error_docref(NULL, E_WARNING, "Using an empty Initialization Vector (iv) is potentially insecure and not recommended");
}
- free_iv = php_openssl_validate_iv(&iv, (int *)&iv_len, max_iv_len);
+ free_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len);
outlen = data_len + EVP_CIPHER_block_size(cipher_type);
outbuf = zend_string_alloc(outlen, 0);
@@ -5230,7 +5230,7 @@ PHP_FUNCTION(openssl_decrypt)
key = (unsigned char*)password;
}
- free_iv = php_openssl_validate_iv(&iv, (int *)&iv_len, EVP_CIPHER_iv_length(cipher_type));
+ free_iv = php_openssl_validate_iv(&iv, &iv_len, EVP_CIPHER_iv_length(cipher_type));
outlen = data_len + EVP_CIPHER_block_size(cipher_type);
outbuf = zend_string_alloc(outlen, 0);
diff --git a/ext/session/session.c b/ext/session/session.c
index ab328573be..7d78b91e54 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -1401,6 +1401,7 @@ static void ppid2sid(zval *ppid) {
PHPAPI void php_session_reset_id(void) /* {{{ */
{
int module_number = PS(module_number);
+ zval *sid;
if (!PS(id)) {
php_error_docref(NULL, E_WARNING, "Cannot set session ID - session ID is not initialized");
@@ -1413,7 +1414,9 @@ PHPAPI void php_session_reset_id(void) /* {{{ */
}
/* if the SID constant exists, destroy it. */
- zend_hash_str_del(EG(zend_constants), "sid", sizeof("sid") - 1);
+ /* We must not delete any items in EG(zend_contants) */
+ /* zend_hash_str_del(EG(zend_constants), "sid", sizeof("sid") - 1); */
+ sid = zend_get_constant_str("SID", sizeof("SID") - 1);
if (PS(define_sid)) {
smart_str var = {0};
@@ -1422,10 +1425,20 @@ PHPAPI void php_session_reset_id(void) /* {{{ */
smart_str_appendc(&var, '=');
smart_str_appends(&var, PS(id)->val);
smart_str_0(&var);
- REGISTER_STRINGL_CONSTANT("SID", var.s->val, var.s->len, 0);
- smart_str_free(&var);
+ if (sid) {
+ zend_string_release(Z_STR_P(sid));
+ ZVAL_STR(sid, var.s);
+ } else {
+ REGISTER_STRINGL_CONSTANT("SID", var.s->val, var.s->len, 0);
+ smart_str_free(&var);
+ }
} else {
- REGISTER_STRINGL_CONSTANT("SID", "", 0, 0);
+ if (sid) {
+ zend_string_release(Z_STR_P(sid));
+ ZVAL_EMPTY_STRING(sid);
+ } else {
+ REGISTER_STRINGL_CONSTANT("SID", "", 0, 0);
+ }
}
if (PS(apply_trans_sid)) {
diff --git a/ext/session/tests/session_regenerate_id_fastshutdown.phpt b/ext/session/tests/session_regenerate_id_fastshutdown.phpt
new file mode 100644
index 0000000000..961965fb74
--- /dev/null
+++ b/ext/session/tests/session_regenerate_id_fastshutdown.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Test session_regenerate_id() function : basic functionality
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--INI--
+opcache.fast_shutdown=1
+--FILE--
+<?php
+session_start();
+define ("user", "foo");
+var_dump(session_regenerate_id());
+?>
+--EXPECT--
+bool(true)