Merge branch 'master' into Closure_apply

This commit is contained in:
Andrea Faulds 2014-08-01 17:02:11 +01:00
commit a748f454a8
33 changed files with 12850 additions and 12649 deletions

3
NEWS
View File

@ -7,6 +7,9 @@ PHP NEWS
(Adam)
. Update the MIME type list from the one shipped by Apache HTTPD. (Adam)
- Core:
. Added PHP_INT_MIN constant. (Andrea)
- DBA:
. Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike)

View File

@ -68,6 +68,8 @@ PHP X.Y UPGRADE NOTES
10. New Global Constants
========================================
- Core
, PHP_INT_MIN added.
========================================
11. Changes to INI File Handling

View File

@ -22,7 +22,7 @@ class foo {
var_dump(foo::bar);
var_dump(a); // Eventually allow that later with array dereferencing of constants
var_dump(a, a[0], a[2], a[2][1], a[3]);
?>
--EXPECTF--
@ -32,4 +32,35 @@ int(1)
int(4)
int(1)
Fatal error: Arrays are not allowed in constants at run-time in %s on line %d
Notice: Undefined offset: 3 in %s on line %d
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
array(2) {
[0]=>
int(3)
[1]=>
array(1) {
[0]=>
int(4)
}
}
}
int(1)
array(2) {
[0]=>
int(3)
[1]=>
array(1) {
[0]=>
int(4)
}
}
array(1) {
[0]=>
int(4)
}
NULL

View File

@ -12,4 +12,12 @@ var_dump(test::TEST);
echo "Done\n";
?>
--EXPECTF--
Fatal error: Arrays are not allowed in constants at run-time in %s on line %d
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
Done

View File

@ -7,5 +7,5 @@ const C = array();
var_dump(C);
?>
--EXPECTF--
Fatal error: Arrays are not allowed in constants at run-time in %sns_059.php on line 4
array(0) {
}

View File

@ -865,13 +865,16 @@ yield_expr:
;
combined_scalar_offset:
combined_scalar '[' dim_offset ']' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
| combined_scalar_offset '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
| T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']' { $1.EA = 0; zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
combined_scalar '[' dim_offset ']' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
| combined_scalar_offset '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
| T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']' { $1.EA = 0; zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
| general_constant '[' dim_offset ']' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
;
combined_scalar:
T_ARRAY '(' array_pair_list ')' { $$ = $3; }
| '[' array_pair_list ']' { $$ = $2; }
T_ARRAY '(' array_pair_list ')' { $$ = $3; }
| '[' array_pair_list ']' { $$ = $2; }
;
function:
T_FUNCTION { $$.u.op.opline_num = CG(zend_lineno); }
@ -1038,20 +1041,22 @@ static_operation:
| '(' static_scalar_value ')' { $$ = $2; }
;
scalar:
T_STRING_VARNAME { $$ = $1; }
| class_name_scalar { $$ = $1; }
| class_constant { $$ = $1; }
general_constant:
class_constant { $$ = $1; }
| namespace_name { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC); }
| T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); $3 = $$; zend_do_fetch_constant(&$$, NULL, &$3, ZEND_RT, 0 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name { char *tmp = estrndup(Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); memcpy(&(tmp[1]), Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); tmp[0] = '\\'; efree(Z_STRVAL($2.u.constant)); Z_STRVAL($2.u.constant) = tmp; ++Z_STRLEN($2.u.constant); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_RT, 0 TSRMLS_CC); }
| common_scalar { $$ = $1; }
| '"' encaps_list '"' { $$ = $2; }
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; }
| T_CLASS_C { if (Z_TYPE($1.u.constant) == IS_CONSTANT) {zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC);} else {$$ = $1;} }
;
scalar:
T_STRING_VARNAME { $$ = $1; }
| general_constant { $$ = $1; }
| class_name_scalar { $$ = $1; }
| common_scalar { $$ = $1; }
| '"' encaps_list '"' { $$ = $2; }
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; }
| T_CLASS_C { if (Z_TYPE($1.u.constant) == IS_CONSTANT) {zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC);} else {$$ = $1;} }
;
static_array_pair_list:
/* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); $$.u.ast = zend_ast_create_constant(&$$.u.constant); }

View File

@ -3772,9 +3772,6 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
}
}
constant_fetch_end:
if (Z_TYPE(EX_T(opline->result.var).tmp_var) == IS_ARRAY) {
zend_error_noreturn(E_ERROR, "Arrays are not allowed in constants at run-time");
}
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}

View File

@ -4036,9 +4036,6 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO
}
}
constant_fetch_end:
if (Z_TYPE(EX_T(opline->result.var).tmp_var) == IS_ARRAY) {
zend_error_noreturn(E_ERROR, "Arrays are not allowed in constants at run-time");
}
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@ -16001,9 +15998,6 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE
}
}
constant_fetch_end:
if (Z_TYPE(EX_T(opline->result.var).tmp_var) == IS_ARRAY) {
zend_error_noreturn(E_ERROR, "Arrays are not allowed in constants at run-time");
}
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}
@ -25613,9 +25607,6 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC
}
}
constant_fetch_end:
if (Z_TYPE(EX_T(opline->result.var).tmp_var) == IS_ARRAY) {
zend_error_noreturn(E_ERROR, "Arrays are not allowed in constants at run-time");
}
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
}

File diff suppressed because it is too large Load Diff

View File

@ -931,8 +931,8 @@ mssqltime = hour12 ":" minutelz ":" secondlz [:.] [0-9]+ meridian;
isoweekday = year4 "-"? "W" weekofyear "-"? [0-7];
isoweek = year4 "-"? "W" weekofyear;
exif = year4 ":" monthlz ":" daylz " " hour24lz ":" minutelz ":" secondlz;
firstdayof = 'first day of'?;
lastdayof = 'last day of'?;
firstdayof = 'first day of';
lastdayof = 'last day of';
backof = 'back of ' hour24 space? meridian?;
frontof = 'front of ' hour24 space? meridian?;

View File

@ -12,6 +12,9 @@ require_once('skipifconnectfailure.inc');
/*** test mysqli_connect 127.0.0.1 ***/
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
if (!mysqli_query($mysql, "SET sql_mode=''"))
printf("[002] Cannot set SQL-Mode, [%d] %s\n", mysqli_errno($mysql), mysqli_error($mysql));
$mysql->query("DROP TABLE IF EXISTS test_warnings");
$mysql->query("CREATE TABLE test_warnings (a int not null) ENGINE=myisam");

View File

@ -226,7 +226,7 @@ php_mysqlnd_net_store_length_size(uint64_t length)
if (length < (uint64_t) L64(16777216)) {
return 4;
}
return 8;
return 9;
}
/* }}} */

View File

@ -780,6 +780,9 @@ PHP_MINIT_FUNCTION(odbc)
REGISTER_LONG_CONSTANT("SQL_TYPE_DATE", SQL_TYPE_DATE, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_TYPE_TIME", SQL_TYPE_TIME, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_TYPE_TIMESTAMP", SQL_TYPE_TIMESTAMP, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_WCHAR", SQL_WCHAR, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_WVARCHAR", SQL_WVARCHAR, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQL_WLONGVARCHAR", SQL_WLONGVARCHAR, CONST_PERSISTENT | CONST_CS);
/*
* SQLSpecialColumns values
@ -943,9 +946,13 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
{
RETCODE rc;
int i;
SQLSMALLINT colnamelen; /* Not used */
SQLLEN displaysize;
SQLSMALLINT colnamelen; /* Not used */
SQLLEN displaysize;
SQLUSMALLINT colfieldid;
int charextraalloc;
colfieldid = SQL_COLUMN_DISPLAY_SIZE;
charextraalloc = 0;
result->values = (odbc_result_value *) safe_emalloc(sizeof(odbc_result_value), result->numcols, 0);
result->longreadlen = ODBCG(defaultlrl);
@ -966,6 +973,9 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
case SQL_VARBINARY:
case SQL_LONGVARBINARY:
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
result->values[i].value = NULL;
break;
@ -976,15 +986,27 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
27, &result->values[i].vallen);
break;
#endif /* HAVE_ADABAS */
case SQL_CHAR:
case SQL_VARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WCHAR:
case SQL_WVARCHAR:
colfieldid = SQL_DESC_OCTET_LENGTH;
#else
charextraalloc = 1;
#endif
default:
rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_DISPLAY_SIZE,
NULL, 0, NULL, &displaysize);
displaysize = displaysize <= result->longreadlen ? displaysize :
result->longreadlen;
rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), colfieldid,
NULL, 0, NULL, &displaysize);
/* Workaround for Oracle ODBC Driver bug (#50162) when fetching TIMESTAMP column */
if (result->values[i].coltype == SQL_TIMESTAMP) {
displaysize += 3;
}
if (charextraalloc) {
/* Since we don't know the exact # of bytes, allocate extra */
displaysize *= 4;
}
result->values[i].value = (char *)emalloc(displaysize + 1);
rc = SQLBindCol(result->stmt, (SQLUSMALLINT)(i+1), SQL_C_CHAR, result->values[i].value,
displaysize + 1, &result->values[i].vallen);
@ -1725,6 +1747,9 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
sql_c_type = SQL_C_BINARY;
}
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[i].coltype) && result->longreadlen <= 0) {
Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
break;
@ -1876,7 +1901,11 @@ PHP_FUNCTION(odbc_fetch_into)
break;
}
if (result->binmode == 1) sql_c_type = SQL_C_BINARY;
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[i].coltype) && result->longreadlen <= 0) {
Z_STRVAL_P(tmp) = STR_EMPTY_ALLOC();
break;
@ -2095,6 +2124,9 @@ PHP_FUNCTION(odbc_result)
break;
}
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[field_ind].coltype)) {
if (result->longreadlen <= 0) {
break;
@ -2132,7 +2164,11 @@ PHP_FUNCTION(odbc_result)
}
/* Reduce fieldlen by 1 if we have char data. One day we might
have binary strings... */
if (result->values[field_ind].coltype == SQL_LONGVARCHAR) {
if ((result->values[field_ind].coltype == SQL_LONGVARCHAR)
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
|| (result->values[field_ind].coltype == SQL_WLONGVARCHAR)
#endif
) {
fieldsize -= 1;
}
/* Don't duplicate result, saves one emalloc.
@ -2248,6 +2284,9 @@ PHP_FUNCTION(odbc_result_all)
}
if (result->binmode <= 1) sql_c_type = SQL_C_BINARY;
case SQL_LONGVARCHAR:
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
case SQL_WLONGVARCHAR:
#endif
if (IS_SQL_LONG(result->values[i].coltype) &&
result->longreadlen <= 0) {
php_printf("<td>Not printable</td>");

View File

@ -115,6 +115,7 @@ PHP_FUNCTION(solid_fetch_prev);
#endif
#define ODBC_TYPE "unixODBC"
#undef ODBCVER
#include <sql.h>
#include <sqlext.h>
#define HAVE_SQL_EXTENDED_FETCH 1
@ -284,7 +285,11 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC);
void odbc_sql_error(ODBC_SQL_ERROR_PARAMS);
#if defined(ODBCVER) && (ODBCVER >= 0x0300)
#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR || x == SQL_WLONGVARCHAR)
#else
#define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR)
#endif
#define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY)
#ifdef ZTS

View File

@ -0,0 +1,69 @@
--TEST--
odbc_exec(): Getting accurate unicode data from query
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
// Test strings
mb_internal_encoding("EUC_JP");
$euc_jp_base64 = 'pdal6aWkpcCl676uyqo=';
$euc_jp = base64_decode($euc_jp_base64);
$ascii = 'abcdefghijklmnopqrstuvwxyz;]=#0123456789';
include 'config.inc';
ini_set("odbc.defaultlrl", 4); // Set artifically low
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'CREATE DATABASE odbcTEST ENCODING=\'EUC_JP\'');
odbc_exec($conn, 'CREATE TABLE FOO (ID INT, CHAR_COL CHAR(200), VARCHAR_COL VARCHAR(200), TEXT_COL TEXT)');
odbc_exec($conn, "INSERT INTO FOO(ID, CHAR_COL, VARCHAR_COL, TEXT_COL) VALUES (1, '$euc_jp', '$euc_jp', '$euc_jp')");
odbc_exec($conn, "INSERT INTO FOO(ID, CHAR_COL, VARCHAR_COL, TEXT_COL) VALUES (2, '$ascii', '$ascii', '$ascii')");
$res = odbc_exec($conn, 'SELECT * FROM FOO ORDER BY ID ASC');
while(odbc_fetch_row($res)) {
$char_col = odbc_result($res, "CHAR_COL");
$varchar_col = odbc_result($res, "VARCHAR_COL");
$id = odbc_result($res, "ID");
$text_col = "";
while (($chunk=odbc_result($res, "TEXT_COL")) !== false) {
$text_col .= $chunk;
}
if ($id == 1) {
$euc_jp_check = $euc_jp . str_repeat(" ", (200 - mb_strlen($euc_jp)));
if (strcmp($char_col, $euc_jp_check) == 0 && strcmp($varchar_col, $euc_jp) == 0 &&
strcmp($text_col, $euc_jp) == 0) {
print "EUC-JP matched\n";
} else {
print "EUC-JP mismatched\n";
}
} else {
$ascii_check = $ascii . str_repeat(" ", (200 - strlen($ascii)));
if (strcmp($char_col, $ascii_check) == 0 && strcmp($varchar_col, $ascii) == 0 &&
strcmp($text_col, $ascii) == 0) {
print "ASCII matched\n";
} else {
print "ASCII mismatched\n";
}
}
}
?>
--EXPECT--
EUC-JP matched
ASCII matched
--CLEAN--
<?php
include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'DROP TABLE FOO');
odbc_exec($conn, 'DROP DATABASE odbcTEST');
?>

View File

@ -24,9 +24,5 @@ resource(%d) of type (odbc result)
bool(false)
resource(%d) of type (odbc result)
bool(false)
Warning: odbc_columns(): SQL error: Failed to fetch error message, SQL state HY000 in SQLColumns in %s on line %d
resource(%d) of type (odbc result)
bool(false)
Warning: odbc_fetch_row() expects parameter 1 to be resource, boolean given in %s on line %d
NULL

View File

@ -12,7 +12,7 @@ $conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn, 'CREATE DATABASE odbcTEST');
odbc_exec($conn, 'CREATE TABLE FOO (TEST INT)');
odbc_exec($conn, 'ALTER TABLE FOO ADD PRIMARY KEY FOO(TEST)');
odbc_exec($conn, 'ALTER TABLE FOO ADD PRIMARY KEY (TEST)');
odbc_exec($conn, 'INSERT INTO FOO VALUES (1)');
odbc_exec($conn, 'INSERT INTO FOO VALUES (2)');

View File

@ -1041,7 +1041,6 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
if (zend_hash_num_elements(&persistent_script->class_table) > 0) {
zend_accel_class_hash_copy(CG(class_table), &persistent_script->class_table, NULL TSRMLS_CC);
}
free_persistent_script(persistent_script, 0); /* free only hashes */
}
#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO
@ -1053,6 +1052,10 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script,
}
#endif
if (!from_shared_memory) {
free_persistent_script(persistent_script, 0); /* free only hashes */
}
return op_array;
}

View File

@ -1760,7 +1760,7 @@ PHP_FUNCTION(openssl_x509_export)
}
/* }}} */
static int php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_bool raw, char **out, int *out_len TSRMLS_DC)
int php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_bool raw, char **out, int *out_len TSRMLS_DC)
{
unsigned char md[EVP_MAX_MD_SIZE];
const EVP_MD *mdtype;
@ -1787,61 +1787,6 @@ static int php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_boo
return SUCCESS;
}
static int php_x509_fingerprint_cmp(X509 *peer, const char *method, const char *expected TSRMLS_DC)
{
char *fingerprint;
int fingerprint_len;
int result = -1;
if (php_openssl_x509_fingerprint(peer, method, 0, &fingerprint, &fingerprint_len TSRMLS_CC) == SUCCESS) {
result = strcmp(expected, fingerprint);
efree(fingerprint);
}
return result;
}
zend_bool php_x509_fingerprint_match(X509 *peer, zval *val TSRMLS_DC)
{
if (Z_TYPE_P(val) == IS_STRING) {
const char *method = NULL;
switch (Z_STRLEN_P(val)) {
case 32:
method = "md5";
break;
case 40:
method = "sha1";
break;
}
return method && php_x509_fingerprint_cmp(peer, method, Z_STRVAL_P(val) TSRMLS_CC) == 0;
} else if (Z_TYPE_P(val) == IS_ARRAY) {
HashPosition pos;
zval **current;
char *key;
uint key_len;
ulong key_index;
for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(val), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_P(val), (void **)&current, &pos) == SUCCESS;
zend_hash_move_forward_ex(Z_ARRVAL_P(val), &pos)
) {
int key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(val), &key, &key_len, &key_index, 0, &pos);
if (key_type == HASH_KEY_IS_STRING
&& Z_TYPE_PP(current) == IS_STRING
&& php_x509_fingerprint_cmp(peer, key, Z_STRVAL_PP(current) TSRMLS_CC) != 0
) {
return 0;
}
}
return 1;
}
return 0;
}
PHP_FUNCTION(openssl_x509_fingerprint)
{
X509 *cert;

View File

@ -75,7 +75,7 @@
#define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))
extern php_stream* php_openssl_get_stream_from_ssl_handle(const SSL *ssl);
extern zend_bool php_x509_fingerprint_match(X509 *peer, zval *val TSRMLS_DC);
extern int php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_bool raw, char **out, int *out_len TSRMLS_DC);
extern int php_openssl_get_ssl_stream_data_index();
extern int php_openssl_get_x509_list_id(void);
@ -267,6 +267,61 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) /* {{{ */
}
/* }}} */
static int php_x509_fingerprint_cmp(X509 *peer, const char *method, const char *expected TSRMLS_DC)
{
char *fingerprint;
int fingerprint_len;
int result = -1;
if (php_openssl_x509_fingerprint(peer, method, 0, &fingerprint, &fingerprint_len TSRMLS_CC) == SUCCESS) {
result = strcmp(expected, fingerprint);
efree(fingerprint);
}
return result;
}
static zend_bool php_x509_fingerprint_match(X509 *peer, zval *val TSRMLS_DC)
{
if (Z_TYPE_P(val) == IS_STRING) {
const char *method = NULL;
switch (Z_STRLEN_P(val)) {
case 32:
method = "md5";
break;
case 40:
method = "sha1";
break;
}
return method && php_x509_fingerprint_cmp(peer, method, Z_STRVAL_P(val) TSRMLS_CC) == 0;
} else if (Z_TYPE_P(val) == IS_ARRAY) {
HashPosition pos;
zval **current;
char *key;
uint key_len;
ulong key_index;
for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(val), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_P(val), (void **)&current, &pos) == SUCCESS;
zend_hash_move_forward_ex(Z_ARRVAL_P(val), &pos)
) {
int key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(val), &key, &key_len, &key_index, 0, &pos);
if (key_type == HASH_KEY_IS_STRING
&& Z_TYPE_PP(current) == IS_STRING
&& php_x509_fingerprint_cmp(peer, key, Z_STRVAL_PP(current) TSRMLS_CC) != 0
) {
return 0;
}
}
return 1;
}
return 0;
}
static zend_bool matches_wildcard_name(const char *subjectname, const char *certname) /* {{{ */
{
char *wildcard = NULL;
@ -276,11 +331,12 @@ static zend_bool matches_wildcard_name(const char *subjectname, const char *cert
return 1;
}
if (!(wildcard = strchr(certname, '*'))) {
/* wildcard, if present, must only be present in the left-most component */
if (!(wildcard = strchr(certname, '*')) || memchr(certname, '.', wildcard - certname)) {
return 0;
}
// 1) prefix, if not empty, must match subject
/* 1) prefix, if not empty, must match subject */
prefix_len = wildcard - certname;
if (prefix_len && strncasecmp(subjectname, certname, prefix_len) != 0) {
return 0;

View File

@ -4308,8 +4308,8 @@ ZEND_METHOD(reflection_class, newInstanceWithoutConstructor)
METHOD_NOTSTATIC(reflection_class_ptr);
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->create_object != NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class that cannot be instantiated without invoking its constructor", ce->name);
if (ce->create_object != NULL && ce->ce_flags & ZEND_ACC_FINAL_CLASS) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class marked as final that cannot be instantiated without invoking its constructor", ce->name);
}
object_init_ex(return_value, ce);

View File

@ -20,13 +20,18 @@ var_dump($class->newInstanceWithoutConstructor());
$class = new ReflectionClass('DateTime');
var_dump($class->newInstanceWithoutConstructor());
$class = new ReflectionClass('Generator');
var_dump($class->newInstanceWithoutConstructor());
--EXPECTF--
object(Foo)#%d (0) {
}
object(stdClass)#%d (0) {
}
object(DateTime)#%d (0) {
}
Fatal error: Uncaught exception 'ReflectionException' with message 'Class DateTime is an internal class that cannot be instantiated without invoking its constructor' in %sReflectionClass_newInstanceWithoutConstructor.php:%d
Fatal error: Uncaught exception 'ReflectionException' with message 'Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor' in %sReflectionClass_newInstanceWithoutConstructor.php:%d
Stack trace:
#0 %sReflectionClass_newInstanceWithoutConstructor.php(%d): ReflectionClass->newInstanceWithoutConstructor()
#1 {main}

View File

@ -14,6 +14,6 @@ $generator = $reflection->newInstance();
var_dump($generator);
?>
--EXPECTF--
string(97) "Class Generator is an internal class that cannot be instantiated without invoking its constructor"
string(%d) "Class Generator is an internal class marked as final that cannot be instantiated without invoking its constructor"
Catchable fatal error: The "Generator" class is reserved for internal use and cannot be manually instantiated in %sbug64007.php on line %d

View File

@ -151,7 +151,9 @@ static void soap_error_handler(int error_num, const char *error_filename, const
if (zend_hash_find(Z_OBJPROP_P(this_ptr),"service", sizeof("service"), (void **)&tmp) != FAILURE) { \
ss = (soapServicePtr)zend_fetch_resource(tmp TSRMLS_CC, -1, "service", NULL, 1, le_service); \
} else { \
ss = NULL; \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not fetch service object"); \
SOAP_SERVER_END_CODE(); \
return; \
} \
}

View File

@ -333,16 +333,12 @@ PHP_FUNCTION(count)
#ifdef HAVE_SPL
/* if not and the object implements Countable we call its count() method */
if (Z_OBJ_HT_P(array)->get_class_entry && instanceof_function(Z_OBJCE_P(array), spl_ce_Countable TSRMLS_CC)) {
zval *mode_zv;
MAKE_STD_ZVAL(mode_zv);
ZVAL_LONG(mode_zv, mode);
zend_call_method_with_1_params(&array, NULL, NULL, "count", &retval, mode_zv);
zend_call_method_with_0_params(&array, NULL, NULL, "count", &retval);
if (retval) {
convert_to_long_ex(&retval);
RETVAL_LONG(Z_LVAL_P(retval));
zval_ptr_dtor(&retval);
}
zval_ptr_dtor(&mode_zv);
return;
}
#endif
@ -1893,7 +1889,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
/* If we did a shift... re-index like it did before */
if (!off_the_end) {
zend_hash_reindex(Z_ARRVAL_P(stack), 1);
} else if (!key_len && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) {
} else if (!key_len && Z_ARRVAL_P(stack)->nNextFreeElement > 0 && index >= Z_ARRVAL_P(stack)->nNextFreeElement - 1) {
Z_ARRVAL_P(stack)->nNextFreeElement = Z_ARRVAL_P(stack)->nNextFreeElement - 1;
}

View File

@ -1,17 +0,0 @@
--TEST--
Bug #67064 (Countable interface prevents using 2nd parameter ($mode) of count() function)
--FILE--
<?php
class Counter implements Countable {
public function count($mode = COUNT_NORMAL) {
var_dump($mode == COUNT_RECURSIVE);
return 1;
}
}
$counter = new Counter;
var_dump(count($counter, COUNT_RECURSIVE));
?>
--EXPECTF--
bool(true)
int(1)

View File

@ -0,0 +1,25 @@
--TEST--
Bug #67693 - incorrect push to empty array
--FILE--
<?php
$array = array(-1 => 0);
array_pop($array);
array_push($array, 0);
array_push($array, 0);
var_dump($array);
echo"\nDone";
?>
--EXPECT--
array(2) {
[0]=>
int(0)
[1]=>
int(0)
}
Done

View File

@ -2195,6 +2195,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", LONG_MAX, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MIN", LONG_MIN, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", sizeof(long), CONST_PERSISTENT | CONST_CS);
#ifdef PHP_WIN32

View File

@ -1,8 +1,8 @@
milter: $(SAPI_MILTER_PATH)
$(SAPI_MILTER_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_SAPI_OBJS)
$(SAPI_MILTER_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_MILTER_OBJS)
$(BUILD_MILTER)
install-milter: $(SAPI_MILTER_PATH)
@$(INSTALL) -m 0755 $(SAPI_MILTER_PATH) $(bindir)/php-milter
@$(INSTALL) -m 0755 $(SAPI_MILTER_PATH) $(INSTALL_ROOT)$(bindir)/php-milter

View File

@ -22,10 +22,10 @@ if test "$PHP_MILTER" != "no"; then
SAPI_MILTER_PATH=sapi/milter/php-milter
PHP_BUILD_THREAD_SAFE
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/milter/Makefile.frag)
PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/sapi/milter/Makefile.frag,$abs_srcdir/sapi/milter,sapi/milter)
PHP_SELECT_SAPI(milter, program, php_milter.c getopt.c,,'$(SAPI_MILTER_PATH)')
PHP_ADD_LIBRARY_WITH_PATH(milter, $MILTERPATH,)
BUILD_MILTER="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_MILTER_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_MILTER_PATH)"
BUILD_MILTER="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_MILTER_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_MILTER_PATH)"
PHP_SUBST(SAPI_MILTER_PATH)
PHP_SUBST(BUILD_MILTER)
fi

View File

@ -525,6 +525,10 @@ static sfsistat mlfi_close(SMFICTX *ctx)
int status;
TSRMLS_FETCH();
if (!SG(sapi_started) && SUCCESS != php_request_startup(TSRMLS_C)) {
return ret;
}
/* call userland */
INIT_ZVAL(function_name);
ZVAL_STRING(&function_name, "milter_close", 0);
@ -550,7 +554,7 @@ static sfsistat mlfi_close(SMFICTX *ctx)
/* {{{ Milter entry struct
*/
struct smfiDesc smfilter = {
static struct smfiDesc smfilter = {
"php-milter", /* filter name */
SMFI_VERSION, /* version code -- leave untouched */
0, /* flags */
@ -1011,6 +1015,7 @@ int main(int argc, char *argv[])
tsrm_startup(1, 1, 0, NULL);
tsrm_ls = ts_resource(0);
sapi_startup(&milter_sapi_module);
while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
@ -1028,7 +1033,6 @@ int main(int argc, char *argv[])
milter_sapi_module.executable_location = argv[0];
tsrm_ls = ts_resource(0);
sapi_module.startup(&milter_sapi_module);

View File

@ -0,0 +1,17 @@
--TEST--
Test PHP_INT_MIN, PHP_INT_MAX and PHP_INT_SIZE (32-bit)
--SKIPIF--
<?php if (PHP_INT_SIZE !== 4)
die("skip this test is for 32-bit platforms only"); ?>
--FILE--
<?php
var_dump(PHP_INT_MIN);
var_dump(PHP_INT_MAX);
var_dump(PHP_INT_SIZE);
?>
--EXPECT--
int(-2147483648)
int(2147483647)
int(4)

View File

@ -0,0 +1,17 @@
--TEST--
Test PHP_INT_MIN, PHP_INT_MAX and PHP_INT_SIZE (64-bit)
--SKIPIF--
<?php if (PHP_INT_SIZE !== 8)
die("skip this test is for 64-bit platforms only"); ?>
--FILE--
<?php
var_dump(PHP_INT_MIN);
var_dump(PHP_INT_MAX);
var_dump(PHP_INT_SIZE);
?>
--EXPECT--
int(-9223372036854775808)
int(9223372036854775807)
int(8)