Browse Source

Merge branch 'master' into finally

pull/196/head
Xinchen Hui 14 years ago
parent
commit
3d4f91da4b
  1. 2
      Zend/zend.h
  2. 1
      ext/mysql/tests/mysql_query_load_data_openbasedir.phpt
  3. 5
      ext/mysqli/mysqli_nonapi.c
  4. 26
      ext/mysqli/tests/bug62885.phpt
  5. 5
      ext/phar/phar.c
  6. 137
      ext/phar/phar_object.c
  7. 13
      ext/phar/stream.c
  8. 5
      ext/phar/tar.c
  9. 16
      ext/phar/zip.c
  10. 54
      ext/zip/tests/bug51353.phpt

2
Zend/zend.h

@ -22,7 +22,7 @@
#ifndef ZEND_H
#define ZEND_H
#define ZEND_VERSION "2.4.0"
#define ZEND_VERSION "2.5.0-dev"
#define ZEND_ENGINE_2

1
ext/mysql/tests/mysql_query_load_data_openbasedir.phpt

@ -2,7 +2,6 @@
LOAD DATA INFILE - open_basedir
--SKIPIF--
<?php
@include_once("connect.inc");
include_once('skipif.inc');
include_once('skipifconnectfailure.inc');

5
ext/mysqli/mysqli_nonapi.c

@ -778,6 +778,11 @@ PHP_FUNCTION(mysqli_poll)
RETURN_FALSE;
}
if (!r_array && !e_array) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No stream arrays were passed");
RETURN_FALSE;
}
if (r_array != NULL) {
mysqlnd_zval_array_to_mysqlnd_array(r_array, &new_r_array TSRMLS_CC);
}

26
ext/mysqli/tests/bug62885.phpt

@ -0,0 +1,26 @@
--TEST--
Bug #62885 (mysqli_poll - Segmentation fault)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once("connect.inc");
if (!$IS_MYSQLND) {
die("skip mysqlnd only test");
}
?>
--FILE--
<?php
error_reporting(E_ALL);
$tablica = array();
$test1 = mysqli_poll($test2, $test3, $tablica, null);
$test2 = array();
$test2 = array();
$test1 = mysqli_poll($test2, $test3, $tablica, null);
echo "okey";
?>
--EXPECTF--
Warning: mysqli_poll(): No stream arrays were passed in %sbug62885.php on line %d
Warning: mysqli_poll(): No stream arrays were passed in %sbug62885.php on line %d
okey

5
ext/phar/phar.c

@ -2647,11 +2647,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
len = -len;
}
user_stub = 0;
#if PHP_MAJOR_VERSION >= 6
if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) {
#else
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
#endif
if (closeoldfile) {
php_stream_close(oldfile);
}

137
ext/phar/phar_object.c

@ -58,9 +58,6 @@ static int phar_file_type(HashTable *mimes, char *file, char **mime_type TSRMLS_
static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len TSRMLS_DC) /* {{{ */
{
#if PHP_MAJOR_VERSION >= 6
int is_unicode = 0;
#endif
HashTable *_SERVER;
zval **stuff;
char *path_info;
@ -76,18 +73,7 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
_SERVER = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]);
/* PATH_INFO and PATH_TRANSLATED should always be munged */
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@ -96,38 +82,19 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO"), &temp, sizeof(zval **), NULL);
}
}
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry);
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED"), (void *) &temp, sizeof(zval **), NULL);
}
@ -136,18 +103,7 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_REQUEST_URI) {
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@ -156,29 +112,14 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_REQUEST_URI", sizeof("PHAR_REQUEST_URI"), (void *) &temp, sizeof(zval **), NULL);
}
}
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_PHP_SELF) {
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@ -187,68 +128,34 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_PHP_SELF", sizeof("PHAR_PHP_SELF"), (void *) &temp, sizeof(zval **), NULL);
}
}
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_NAME) {
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
ZVAL_STRINGL(*stuff, entry, entry_len, 1);
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_SCRIPT_NAME", sizeof("PHAR_SCRIPT_NAME"), (void *) &temp, sizeof(zval **), NULL);
}
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_FILENAME) {
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry);
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME"), (void *) &temp, sizeof(zval **), NULL);
}
}
@ -942,11 +849,7 @@ PHP_METHOD(Phar, webPhar)
if (ext) {
++ext;
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val TSRMLS_CC)) {
#else
if (SUCCESS == zend_hash_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val)) {
#endif
switch (Z_TYPE_PP(val)) {
case IS_LONG:
if (Z_LVAL_PP(val) == PHAR_MIME_PHP || Z_LVAL_PP(val) == PHAR_MIME_PHPS) {
@ -960,11 +863,6 @@ PHP_METHOD(Phar, webPhar)
RETURN_FALSE;
}
break;
#if PHP_MAJOR_VERSION >= 6
case IS_UNICODE:
zval_unicode_to_string(*(val) TSRMLS_CC);
/* break intentionally omitted */
#endif
case IS_STRING:
mime_type = Z_STRVAL_PP(val);
code = PHAR_MIME_OTHER;
@ -1015,26 +913,12 @@ PHP_METHOD(Phar, mungServer)
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(mungvalues)); SUCCESS == zend_hash_has_more_elements(Z_ARRVAL_P(mungvalues)); zend_hash_move_forward(Z_ARRVAL_P(mungvalues))) {
zval **data = NULL;
#if PHP_MAJOR_VERSION >= 6
zval *unicopy = NULL;
#endif
if (SUCCESS != zend_hash_get_current_data(Z_ARRVAL_P(mungvalues), (void **) &data)) {
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "unable to retrieve array value in Phar::mungServer()");
return;
}
#if PHP_MAJOR_VERSION >= 6
if (Z_TYPE_PP(data) == IS_UNICODE) {
MAKE_STD_ZVAL(unicopy);
*unicopy = **data;
zval_copy_ctor(unicopy);
INIT_PZVAL(unicopy);
zval_unicode_to_string(unicopy TSRMLS_CC);
data = &unicopy;
}
#endif
if (Z_TYPE_PP(data) != IS_STRING) {
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
return;
@ -1056,11 +940,6 @@ PHP_METHOD(Phar, mungServer)
if (Z_STRLEN_PP(data) == sizeof("SCRIPT_FILENAME")-1 && !strncmp(Z_STRVAL_PP(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) {
PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_SCRIPT_FILENAME;
}
#if PHP_MAJOR_VERSION >= 6
if (unicopy) {
zval_ptr_dtor(&unicopy);
}
#endif
}
}
/* }}} */
@ -5037,11 +4916,7 @@ PHP_METHOD(PharFileInfo, getContent)
phar_seek_efp(link, 0, SEEK_SET, 0, 0 TSRMLS_CC);
Z_TYPE_P(return_value) = IS_STRING;
#if PHP_MAJOR_VERSION >= 6
Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, (void **) &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0);
#else
Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0);
#endif
if (!Z_STRVAL_P(return_value)) {
Z_STRVAL_P(return_value) = estrndup("", 0);

13
ext/phar/stream.c

@ -207,30 +207,19 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, char *pat
fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
php_url_free(resource);
efree(internal_file);
#if PHP_MAJOR_VERSION >= 6
if (context && context->options && phar_find_key(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption TSRMLS_CC)) {
#else
if (context && context->options && zend_hash_find(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption) == SUCCESS) {
#endif
pharcontext = HASH_OF(*pzoption);
if (idata->internal_file->uncompressed_filesize == 0
&& idata->internal_file->compressed_filesize == 0
#if PHP_MAJOR_VERSION >= 6
&& phar_find_key(pharcontext, "compress", sizeof("compress"), (void**)&pzoption TSRMLS_CC)
#else
&& zend_hash_find(pharcontext, "compress", sizeof("compress"), (void**)&pzoption) == SUCCESS
#endif
&& Z_TYPE_PP(pzoption) == IS_LONG
&& (Z_LVAL_PP(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0
) {
idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK;
idata->internal_file->flags |= Z_LVAL_PP(pzoption);
}
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption TSRMLS_CC)) {
#else
if (zend_hash_find(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption) == SUCCESS) {
#endif
if (idata->internal_file->metadata) {
zval_ptr_dtor(&idata->internal_file->metadata);
idata->internal_file->metadata = NULL;

5
ext/phar/tar.c

@ -986,11 +986,8 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
len = -len;
}
user_stub = 0;
#if PHP_MAJOR_VERSION >= 6
if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) {
#else
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
#endif
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new tar-based phar \"%s\"", phar->fname);
}

16
ext/phar/zip.c

@ -603,11 +603,7 @@ foundit:
php_stream_filter_append(&fp->readfilters, filter);
#if PHP_MAJOR_VERSION >= 6
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#else
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#endif
pefree(entry.filename, entry.is_persistent);
#if PHP_VERSION_ID < 50207
PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)");
@ -628,11 +624,7 @@ foundit:
php_stream_filter_append(&fp->readfilters, filter);
#if PHP_MAJOR_VERSION >= 6
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#else
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#endif
pefree(entry.filename, entry.is_persistent);
#if PHP_VERSION_ID < 50207
PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)");
@ -643,11 +635,7 @@ foundit:
php_stream_filter_flush(filter, 1);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
} else {
#if PHP_MAJOR_VERSION >= 6
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#else
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#endif
pefree(entry.filename, entry.is_persistent);
PHAR_ZIP_FAIL("unable to read in alias, truncated");
}
@ -1252,11 +1240,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
user_stub = 0;
#if PHP_MAJOR_VERSION >= 6
if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) {
#else
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
#endif
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new zip-based phar \"%s\"", phar->fname);
}

54
ext/zip/tests/bug51353.phpt

@ -0,0 +1,54 @@
--TEST--
Bug #51353 ZIP64 problem, archive with 100000 items
--SKIPIF--
<?php
if(!extension_loaded('zip')) die('skip');
die('skip the test might get very long, activate it manually');
--FILE--
<?php
/* This test might get very long depending on the mashine it's running on. Therefore
adding an explicit skip, remove it to run this test. */
set_time_limit(0);
$base_path = dirname(__FILE__);
/* Either we ship a file with 100000 entries which would be >12M big,
or create it dynamically. */
$zip = new ZipArchive;
$r = $zip->open("$base_path/51353.zip", ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
if ($r) {
for ($i = 0; $i < 100000; $i++) {
$zip->addFromString("$i.txt", '1');
}
$zip->close();
} else {
die("failed");
}
$zip = new ZipArchive;
$r = $zip->open("$base_path/51353.zip");
if ($r) {
$zip->extractTo("$base_path/51353_unpack");
$zip->close();
$a = glob("$base_path/51353_unpack/*.txt");
echo count($a) . "\n";
} else {
die("failed");
}
echo "OK";
--CLEAN--
<?php
$base_path = dirname(__FILE__);
unlink("$base_path/51353.zip");
$a = glob("$base_path/51353_unpack/*.txt");
foreach($a as $f) {
unlink($f);
}
rmdir("$base_path/51353_unpack");
--EXPECT--
100000
OK
Loading…
Cancel
Save