Compare commits

..
Author SHA1 Message Date
Christoph M. Becker a20c3d4f45 Bump version to 7.3.20RC1 2020-06-23 09:17:34 +02:00
101 changed files with 709 additions and 1517 deletions

No files matched your search

+1 -87
View File
@@ -1,92 +1,6 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
20 Aug 2020, PHP 7.3.22RC1
- Core:
. Fixed bug #79884 (PHP_CONFIG_FILE_PATH is meaningless). (cmb)
. Fixed bug #77932 (File extensions are case-sensitive). (cmb)
. Fixed bug #79806 (realpath() erroneously resolves link to link). (cmb)
. Fixed bug #79895 (PHP_CHECK_GCC_ARG does not allow flags with equal sign).
(Santiago M. Mola)
. Fixed bug #79919 (Stack use-after-scope in define()). (cmb)
. Fixed bug #79934 (CRLF-only line in heredoc causes parsing error).
(Pieter van den Ham)
- COM:
. Fixed bug #48585 (com_load_typelib holds reference, fails on second call).
(cmb)
- Exif:
. Fixed bug #75785 (Many errors from exif_read_data).
(Níckolas Daniel da Silva)
- Gettext:
. Fixed bug #70574 (Tests fail due to relying on Linux fallback behavior for
gettext()). (Florian Engelhardt)
- LDAP:
. Fixed memory leaks. (ptomulik)
- OPcache:
. Fixed bug #73060 (php failed with error after temp folder cleaned up).
(cmb)
- PDO:
. Fixed bug #64705 (errorInfo property of PDOException is null when
PDO::__construct() fails). (Ahmed Abdou)
- Standard:
. Fixed bug #79930 (array_merge_recursive() crashes when called with array
with single reference). (Nikita)
. Fixed bug #79944 (getmxrr always returns true on Alpine linux). (Nikita)
. Fixed bug #79951 (Memory leak in str_replace of empty string). (Nikita)
- XML:
. Fixed bug #79922 (Crash after multiple calls to xml_parser_free()). (cmb)
06 Aug 2020, PHP 7.3.21
- Apache:
. Fixed bug #79030 (Upgrade apache2handler's php_apache_sapi_get_request_time
to return usec). (Herbert256)
- Core:
. Fixed bug #79877 (getimagesize function silently truncates after a null
byte) (cmb)
. Fixed bug #79778 (Assertion failure if dumping closure with unresolved
static variable). (Nikita)
. Fixed bug #79792 (HT iterators not removed if empty array is destroyed).
(Nikita)
- COM:
. Fixed bug #63208 (BSTR to PHP string conversion not binary safe). (cmb)
. Fixed bug #63527 (DCOM does not work with Username, Password parameter).
(cmb)
- Curl:
. Fixed bug #79741 (curl_setopt CURLOPT_POSTFIELDS asserts on object with
declared properties). (Nikita)
- Fileinfo:
. Fixed bug #79756 (finfo_file crash (FILEINFO_MIME)). (cmb)
- FTP:
. Fixed bug #55857 (ftp_size on large files). (cmb)
- Mbstring:
. Fixed bug #79787 (mb_strimwidth does not trim string). (XXiang)
- Phar:
. Fixed bug #79797 (Use of freed hash key in the phar_parse_zipfile
function). (CVE-2020-7068) (cmb)
- Standard:
. Fixed bug #70362 (Can't copy() large 'data://' with open_basedir). (cmb)
. Fixed bug #79817 (str_replace() does not handle INDIRECT elements). (Nikita)
. Fixed bug #78008 (dns_check_record() always return true on Alpine).
(Andy Postnikov)
09 Jul 2020, PHP 7.3.20
25 Jun 2020, PHP 7.3.20RC1
- Core:
. Fixed bug #79650 (php-win.exe 100% cpu lockup). (cmb)
+1 -1
View File
@@ -26,7 +26,7 @@ namespace N2 {
echo $a->hello(), PHP_EOL;
echo $a->foo(), PHP_EOL;
try {
} catch(namespace\Foo $e)
} catch(namespace \Foo $e)
{
}
}
-26
View File
@@ -1,26 +0,0 @@
--TEST--
Bug #79778: Assertion failure if dumping closure with unresolved static variable
--FILE--
<?php
$closure1 = function() {
static $var = CONST_REF;
};
var_dump($closure1);
print_r($closure1);
?>
--EXPECT--
object(Closure)#1 (1) {
["static"]=>
array(1) {
["var"]=>
string(14) "<constant ast>"
}
}
Closure Object
(
[static] => Array
(
[var] => <constant ast>
)
)
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Bug #79792: HT iterators not removed if empty array is destroyed
--FILE--
<?php
$a = [42];
foreach ($a as &$c) {
// Make the array empty.
unset($a[0]);
// Destroy the array.
$a = null;
}
?>
===DONE===
--EXPECTF--
Warning: Invalid argument supplied for foreach() in %s on line %d
===DONE===
-14
View File
@@ -1,14 +0,0 @@
--TEST--
Bug #79919 (Stack use-after-scope in define())
--SKIPIF--
<?php
if (!extension_loaded('simplexml')) die('skip simplexml extension not available');
?>
--FILE--
<?php
$b = error_log(0);
$b = simplexml_load_string('<xml/>', null, $b);
define(0, $b);
?>
--EXPECT--
0
-29
View File
@@ -1,29 +0,0 @@
--TEST--
Bug #79934: CRLF-only line in heredoc causes parsing error
--DESCRIPTION--
This test covers different variations of whitespace-only lines in heredoc strings.
These whitespace-only lines should be ignored when stripping indentation.
--FILE--
<?php
// lines with only CRLF should not cause a parse error
eval("\$s1 = <<<HEREDOC\r\n a\r\n\r\n b\r\n HEREDOC;");
var_dump(addcslashes($s1, "\r\n"));
// lines with only a LF should not cause a parse error
eval("\$s2 = <<<HEREDOC\n a\n\n b\n HEREDOC;");
var_dump(addcslashes($s2, "\n"));
// lines with only a CR should not cause a parse error
eval("\$s3 = <<<HEREDOC\r a\r\r b\r HEREDOC;");
var_dump(addcslashes($s3, "\r"));
// lines with only whitespace should not cause a parse error
eval("\$s4 = <<<HEREDOC\r a\r\n \r\n b\r HEREDOC;");
var_dump(addcslashes($s4, "\n\r"));
?>
--EXPECT--
string(10) "a\r\n\r\nb"
string(6) "a\n\nb"
string(6) "a\r\rb"
string(10) "a\r\n\r\nb"
@@ -1,20 +0,0 @@
--TEST--
Leak when setting recursive previous exception in finally handling
--FILE--
<?php
try {
try {
throw new Exception("Test");
} catch (Exception $e) {
throw $e;
} finally {
throw $e;
}
} catch (Exception $e2) {
echo $e2->getMessage(), "\n";
}
?>
--EXPECT--
Test
+1 -1
View File
@@ -20,7 +20,7 @@
#ifndef ZEND_H
#define ZEND_H
#define ZEND_VERSION "3.3.22RC1"
#define ZEND_VERSION "3.3.20RC1"
#define ZEND_ENGINE_3
+3 -1
View File
@@ -882,7 +882,9 @@ repeat:
case IS_OBJECT:
if (Z_TYPE(val_free) == IS_UNDEF) {
if (Z_OBJ_HT_P(val)->get) {
val = Z_OBJ_HT_P(val)->get(val, &val_free);
zval rv;
val = Z_OBJ_HT_P(val)->get(val, &rv);
ZVAL_COPY_VALUE(&val_free, val);
goto repeat;
} else if (Z_OBJ_HT_P(val)->cast_object) {
if (Z_OBJ_HT_P(val)->cast_object(val, &val_free, IS_STRING) == SUCCESS) {
-7
View File
@@ -506,16 +506,9 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{
debug_info = zend_new_array(8);
if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) {
zval *var;
HashTable *static_variables = closure->func.op_array.static_variables;
ZVAL_ARR(&val, zend_array_dup(static_variables));
zend_hash_update(debug_info, ZSTR_KNOWN(ZEND_STR_STATIC), &val);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL(val), var) {
if (Z_TYPE_P(var) == IS_CONSTANT_AST) {
zval_ptr_dtor(var);
ZVAL_STRING(var, "<constant ast>");
}
} ZEND_HASH_FOREACH_END();
}
if (Z_TYPE(closure->this_ptr) != IS_UNDEF) {
+1 -7
View File
@@ -76,15 +76,9 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
zval pv, zv, rv;
zend_class_entry *base_ce;
if (!exception || !add_previous) {
if (exception == add_previous || !add_previous || !exception) {
return;
}
if (exception == add_previous) {
OBJ_RELEASE(add_previous);
return;
}
ZVAL_OBJ(&pv, add_previous);
if (!instanceof_function(Z_OBJCE(pv), zend_ce_throwable)) {
zend_error_noreturn(E_CORE_ERROR, "Previous exception must implement Throwable");
+4
View File
@@ -253,6 +253,10 @@ static void zend_generator_free_storage(zend_object *object) /* {{{ */
}
zend_object_std_dtor(&generator->std);
if (generator->iterator) {
zend_iterator_dtor(generator->iterator);
}
}
/* }}} */
+2 -2
View File
@@ -1504,11 +1504,11 @@ ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
}
} while (++p != end);
}
zend_hash_iterators_remove(ht);
SET_INCONSISTENT(HT_DESTROYED);
} else if (EXPECTED(!(HT_FLAGS(ht) & HASH_FLAG_INITIALIZED))) {
goto free_ht;
}
zend_hash_iterators_remove(ht);
SET_INCONSISTENT(HT_DESTROYED);
efree(HT_GET_DATA_ADDR(ht));
free_ht:
FREE_HASHTABLE(ht);
File diff suppressed because it is too large. Load diff
-1
View File
@@ -1112,7 +1112,6 @@ static const char *next_newline(const char *str, const char *end, size_t *newlin
for (; str < end; str++) {
if (*str == '\r') {
*newline_len = str + 1 < end && *(str + 1) == '\n' ? 2 : 1;
return str;
} else if (*str == '\n') {
*newline_len = 1;
return str;
+2 -1
View File
@@ -1,4 +1,5 @@
/* Generated by re2c 1.3 */
/* Generated by re2c 1.0.1 */
#line 3 "Zend/zend_language_scanner_defs.h"
enum YYCONDTYPE {
yycST_IN_SCRIPTING,
+2 -19
View File
@@ -845,7 +845,6 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
}
#ifdef ZEND_WIN32
retry_reparse_point:
if (save) {
pathw = php_win32_ioutil_any_to_w(path);
if (!pathw) {
@@ -868,7 +867,7 @@ retry_reparse_point:
tmp = do_alloca(len+1, use_heap);
memcpy(tmp, path, len+1);
retry_reparse_tag_cloud:
retry:
if(save &&
!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
(dataw.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
@@ -929,7 +928,7 @@ retry_reparse_tag_cloud:
dataw.dwFileAttributes = fileInformation.dwFileAttributes;
CloseHandle(hLink);
(*ll)--;
goto retry_reparse_tag_cloud;
goto retry;
}
free_alloca(tmp, use_heap);
CloseHandle(hLink);
@@ -1076,22 +1075,6 @@ retry_reparse_tag_cloud:
free_alloca(pbuffer, use_heap_large);
free(substitutename);
{
DWORD attrs;
FREE_PATHW()
pathw = php_win32_ioutil_any_to_w(path);
if (!pathw) {
return (size_t)-1;
}
attrs = GetFileAttributesW(pathw);
if (!isVolume && attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_REPARSE_POINT)) {
free_alloca(tmp, use_heap);
FREE_PATHW()
goto retry_reparse_point;
}
}
if(isabsolute == 1) {
if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) {
/* use_realpath is 0 in the call below coz path is absolute*/
+2 -2
View File
@@ -329,8 +329,8 @@ dnl
dnl PHP_CHECK_GCC_ARG(arg, action-if-found, action-if-not-found)
dnl
AC_DEFUN([PHP_CHECK_GCC_ARG],[
gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z=-,a-z__)
AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z=-,a-z__), [
gcc_arg_name=[ac_cv_gcc_arg]translit($1,A-Z-,a-z_)
AC_CACHE_CHECK([whether $CC supports $1], [ac_cv_gcc_arg]translit($1,A-Z-,a-z_), [
echo 'void somefunc() { };' > conftest.c
cmd='$CC $1 -c conftest.c'
if eval $cmd 2>&1 | $EGREP -e $1 >/dev/null ; then
+1 -1
View File
@@ -107,7 +107,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=7
PHP_MINOR_VERSION=3
PHP_RELEASE_VERSION=22
PHP_RELEASE_VERSION=20
PHP_EXTRA_VERSION="RC1"
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
+5 -3
View File
@@ -133,7 +133,7 @@ PHP_FUNCTION(com_create_instance)
info.pwszName = php_com_string_to_olestring(server_name, server_name_len, obj->code_page);
if (user_name) {
authid.User = (OLECHAR*)user_name;
authid.User = php_com_string_to_olestring(user_name, -1, obj->code_page);
authid.UserLength = (ULONG)user_name_len;
if (password) {
@@ -248,7 +248,7 @@ PHP_FUNCTION(com_create_instance)
TL = php_com_load_typelib_via_cache(typelib_name, obj->code_page, &cached);
if (TL) {
if (COMG(autoreg_on)) {
if (COMG(autoreg_on) && !cached) {
php_com_import_typelib(TL, mode, obj->code_page);
}
@@ -838,7 +838,9 @@ PHP_FUNCTION(com_load_typelib)
php_com_initialize();
pTL = php_com_load_typelib_via_cache(name, codepage, &cached);
if (pTL) {
if (php_com_import_typelib(pTL, cs ? CONST_CS : 0, codepage) == SUCCESS) {
if (cached) {
RETVAL_TRUE;
} else if (php_com_import_typelib(pTL, cs ? CONST_CS : 0, codepage) == SUCCESS) {
RETVAL_TRUE;
}
+3 -1
View File
@@ -252,7 +252,9 @@ static PHP_INI_MH(OnTypeLibFileUpdate)
}
if ((pTL = php_com_load_typelib_via_cache(typelib_name, COMG(code_page), &cached)) != NULL) {
php_com_import_typelib(pTL, mode, COMG(code_page));
if (!cached) {
php_com_import_typelib(pTL, mode, COMG(code_page));
}
ITypeLib_Release(pTL);
}
}
-55
View File
@@ -103,58 +103,3 @@ PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring, size_t
return string;
}
BSTR php_com_string_to_bstr(zend_string *string, int codepage)
{
BSTR bstr = NULL;
DWORD flags = codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS;
size_t mb_len = ZSTR_LEN(string);
int wc_len;
if ((wc_len = MultiByteToWideChar(codepage, flags, ZSTR_VAL(string), (int)mb_len + 1, NULL, 0)) <= 0) {
goto fail;
}
if ((bstr = SysAllocStringLen(NULL, (UINT)(wc_len - 1))) == NULL) {
goto fail;
}
if ((wc_len = MultiByteToWideChar(codepage, flags, ZSTR_VAL(string), (int)mb_len + 1, bstr, wc_len)) <= 0) {
goto fail;
}
return bstr;
fail:
char *msg = php_win32_error_to_msg(GetLastError());
php_error_docref(NULL, E_WARNING,
"Could not convert string to unicode: `%s'", msg);
LocalFree(msg);
SysFreeString(bstr);
return SysAllocString(L"");
}
zend_string *php_com_bstr_to_string(BSTR bstr, int codepage)
{
zend_string *string = NULL;
UINT wc_len = SysStringLen(bstr);
int mb_len;
mb_len = WideCharToMultiByte(codepage, 0, bstr, wc_len + 1, NULL, 0, NULL, NULL);
if (mb_len > 0) {
string = zend_string_alloc(mb_len - 1, 0);
mb_len = WideCharToMultiByte(codepage, 0, bstr, wc_len + 1, ZSTR_VAL(string), mb_len, NULL, NULL);
}
if (mb_len <= 0) {
char *msg = php_win32_error_to_msg(GetLastError());
php_error_docref(NULL, E_WARNING,
"Could not convert string from unicode: `%s'", msg);
LocalFree(msg);
if (string != NULL) {
zend_string_release(string);
}
string = ZSTR_EMPTY_ALLOC();
}
return string;
}
+14 -3
View File
@@ -96,6 +96,7 @@ bogus:
PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage)
{
OLECHAR *olestring;
php_com_dotnet_object *obj;
zend_uchar ztype = IS_NULL;
@@ -163,7 +164,13 @@ PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z, int codep
case IS_STRING:
V_VT(v) = VT_BSTR;
V_BSTR(v) = php_com_string_to_bstr(Z_STR_P(z), codepage);
olestring = php_com_string_to_olestring(Z_STRVAL_P(z), Z_STRLEN_P(z), codepage);
if (CP_UTF8 == codepage) {
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(wcslen(olestring) * sizeof(OLECHAR)));
} else {
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, (UINT)(Z_STRLEN_P(z) * sizeof(OLECHAR)));
}
efree(olestring);
break;
case IS_RESOURCE:
@@ -229,8 +236,12 @@ PHP_COM_DOTNET_API int php_com_zval_from_variant(zval *z, VARIANT *v, int codepa
case VT_BSTR:
olestring = V_BSTR(v);
if (olestring) {
zend_string *str = php_com_bstr_to_string(olestring, codepage);
ZVAL_STR(z, str);
size_t len;
char *str = php_com_olestring_to_string(olestring,
&len, codepage);
ZVAL_STRINGL(z, str, len);
// TODO: avoid reallocation???
efree(str);
olestring = NULL;
}
break;
-2
View File
@@ -89,8 +89,6 @@ PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring,
size_t *string_len, int codepage);
PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string,
size_t string_len, int codepage);
BSTR php_com_string_to_bstr(zend_string *string, int codepage);
zend_string *php_com_bstr_to_string(BSTR bstr, int codepage);
/* com_com.c */
-17
View File
@@ -1,17 +0,0 @@
--TEST--
Bug #63208 (BSTR to PHP string conversion not binary safe)
--SKIPIF--
<?php
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
?>
--FILE--
<?php
$string = "\u{0905}b\0cd";
$variant = new VARIANT($string, VT_ARRAY | VT_UI1, CP_UTF8); // Array of bytes
$converted = (string) $variant;
var_dump(bin2hex($string));
var_dump(bin2hex($converted));
?>
--EXPECT--
string(14) "e0a48562006364"
string(14) "e0a48562006364"
+2 -2
View File
@@ -2719,7 +2719,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
return FAILURE;
}
ZEND_HASH_FOREACH_VAL_IND(ph, current) {
ZEND_HASH_FOREACH_VAL(ph, current) {
ZVAL_DEREF(current);
val = zval_get_tmp_string(current, &tmp_val);
slist = curl_slist_append(slist, ZSTR_VAL(val));
@@ -2797,7 +2797,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
}
#endif
ZEND_HASH_FOREACH_KEY_VAL_IND(postfields, num_key, string_key, current) {
ZEND_HASH_FOREACH_KEY_VAL(postfields, num_key, string_key, current) {
zend_string *postval, *tmp_postval;
/* Pretend we have a string_key here */
if (!string_key) {
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Bug #79741: curl_setopt CURLOPT_POSTFIELDS asserts on object with declared properties
--FILE--
<?php
class Test {
public $prop = "value";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, new Test);
?>
===DONE===
--EXPECT--
===DONE===
+10 -18
View File
@@ -66,7 +66,7 @@ typedef unsigned char uchar;
#define EFREE_IF(ptr) if (ptr) efree(ptr)
#define MAX_IFD_NESTING_LEVEL 200
#define MAX_IFD_NESTING_LEVEL 150
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO(arginfo_exif_tagname, 0)
@@ -3173,23 +3173,6 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel);
/* It can be that motorola_intel is wrongly mapped, let's try inverting it */
if ((2+NumDirEntries*12) > value_len) {
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Potentially invalid endianess, trying again with different endianness before imminent failure.");
ImageInfo->motorola_intel = ImageInfo->motorola_intel == 0 ? 1 : 0;
NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel);
}
if ((2+NumDirEntries*12) > value_len) {
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 2 + 0x%04X*12 = 0x%04X > 0x%04X", NumDirEntries, 2+NumDirEntries*12, value_len);
return FALSE;
}
if ((dir_start - value_ptr) > value_len - (2+NumDirEntries*12)) {
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 0x%04X > 0x%04X", (dir_start - value_ptr) + (2+NumDirEntries*12), value_len);
return FALSE;
}
switch (maker_note->offset_mode) {
case MN_OFFSET_MAKER:
offset_base = value_ptr;
@@ -3220,6 +3203,15 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
break;
}
if ((2+NumDirEntries*12) > value_len) {
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 2 + 0x%04X*12 = 0x%04X > 0x%04X", NumDirEntries, 2+NumDirEntries*12, value_len);
return FALSE;
}
if ((dir_start - value_ptr) > value_len - (2+NumDirEntries*12)) {
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 0x%04X > 0x%04X", (dir_start - value_ptr) + (2+NumDirEntries*12), value_len);
return FALSE;
}
for (de=0;de<NumDirEntries;de++) {
size_t offset = 2 + 12 * de;
if (!exif_process_IFD_TAG(ImageInfo, dir_start + offset,
Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

-17
View File
@@ -1,17 +0,0 @@
--TEST--
Bug #75785 fix corrupt EXIF header issues; Related to mixed endianness. (Thank you @Richard Matzinger for providing the test photo)
--SKIPIF--
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
--FILE--
<?php
$mixedEndiannessFile = dirname(__FILE__).'/P1000506.JPG';
$tags = exif_read_data($mixedEndiannessFile, 'EXIF', true, false);
echo $tags['GPS']['GPSLatitude'][0] . PHP_EOL;
echo $tags['GPS']['GPSLongitude'][0] . PHP_EOL;
?>
===DONE===
--EXPECTF--
38/1
122/1
===DONE===
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Bug #79756 (finfo_file crash (FILEINFO_MIME))
--SKIPIF--
<?php
if (!extension_loaded('fileinfo')) die('skip fileinfo extension not available');
?>
--FILE--
<?php
$filename = __DIR__ . '/bug79756.xls';
$finfo = finfo_open(FILEINFO_MIME);
$mime = finfo_file($finfo, $filename);
finfo_close($finfo);
echo $mime;
?>
--EXPECT--
application/vnd.ms-excel; charset=binary
Binary file not shown.
+1 -4
View File
@@ -1133,8 +1133,6 @@ bail:
zend_long
ftp_size(ftpbuf_t *ftp, const char *path, const size_t path_len)
{
zend_long res;
if (ftp == NULL) {
return -1;
}
@@ -1147,8 +1145,7 @@ ftp_size(ftpbuf_t *ftp, const char *path, const size_t path_len)
if (!ftp_getresp(ftp) || ftp->resp != 213) {
return -1;
}
ZEND_ATOL(res, ftp->inbuf);
return res;
return atol(ftp->inbuf);
}
/* }}} */
+109 -133
View File
@@ -167,17 +167,15 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array,
}
} else if (strcmp(ctrl->ldctl_oid, LDAP_CONTROL_PAGEDRESULTS) == 0) {
int lestimated, rc;
struct berval lcookie = { 0L, NULL };
struct berval lcookie;
zval value;
if (ctrl->ldctl_value.bv_len) {
/* ldap_parse_pageresponse_control() allocates lcookie.bv_val */
rc = ldap_parse_pageresponse_control(ld, ctrl, &lestimated, &lcookie);
} else {
/* ldap_parse_pageresponse_control will crash if value is empty */
rc = -1;
}
if ( rc == LDAP_SUCCESS ) {
array_init(&value);
add_assoc_long(&value, "size", lestimated);
@@ -186,10 +184,6 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array,
} else {
add_assoc_null(array, "value");
}
if (lcookie.bv_val) {
ldap_memfree(lcookie.bv_val);
}
} else if ((strcmp(ctrl->ldctl_oid, LDAP_CONTROL_PRE_READ) == 0) || (strcmp(ctrl->ldctl_oid, LDAP_CONTROL_POST_READ) == 0)) {
BerElement *ber;
struct berval bv;
@@ -289,8 +283,7 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
int control_iscritical = 0, rc = LDAP_SUCCESS;
char** ldap_attrs = NULL;
LDAPSortKey** sort_keys = NULL;
zend_string *tmpstring = NULL, **tmpstrings1 = NULL, **tmpstrings2 = NULL;
size_t num_tmpstrings1 = 0, num_tmpstrings2 = 0;
zend_string *tmpstring = NULL;
if ((val = zend_hash_str_find(Z_ARRVAL_P(array), "oid", sizeof("oid") - 1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Control must have an oid key");
@@ -308,23 +301,27 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
control_iscritical = 0;
}
BerElement *ber = NULL;
struct berval control_value = { 0L, NULL };
int control_value_alloc = 0;
struct berval *control_value = NULL;
if ((val = zend_hash_str_find(Z_ARRVAL_P(array), "value", sizeof("value") - 1)) != NULL) {
if (Z_TYPE_P(val) != IS_ARRAY) {
tmpstring = zval_get_string(val);
if (EG(exception)) {
control_value = ber_memalloc(sizeof * control_value);
if (control_value == NULL) {
rc = -1;
goto failure;
php_error_docref(NULL, E_WARNING, "Failed to allocate control value");
} else {
tmpstring = zval_get_string(val);
if (EG(exception)) {
rc = -1;
goto failure;
}
control_value->bv_val = ZSTR_VAL(tmpstring);
control_value->bv_len = ZSTR_LEN(tmpstring);
}
control_value.bv_val = ZSTR_VAL(tmpstring);
control_value.bv_len = ZSTR_LEN(tmpstring);
} else if (strcmp(ZSTR_VAL(control_oid), LDAP_CONTROL_PAGEDRESULTS) == 0) {
zval* tmp;
int pagesize = 1;
struct berval cookie = { 0L, NULL };
struct berval cookie = { 0, NULL };
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(val), "size", sizeof("size") - 1)) != NULL) {
pagesize = zval_get_long(tmp);
}
@@ -337,11 +334,15 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
cookie.bv_val = ZSTR_VAL(tmpstring);
cookie.bv_len = ZSTR_LEN(tmpstring);
}
/* ldap_create_page_control_value() allocates memory for control_value.bv_val */
control_value_alloc = 1;
rc = ldap_create_page_control_value(ld, pagesize, &cookie, &control_value);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Failed to create paged result control value: %s (%d)", ldap_err2string(rc), rc);
control_value = ber_memalloc(sizeof * control_value);
if (control_value == NULL) {
rc = -1;
php_error_docref(NULL, E_WARNING, "Failed to allocate control value");
} else {
rc = ldap_create_page_control_value(ld, pagesize, &cookie, control_value);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Failed to create paged result control value: %s (%d)", ldap_err2string(rc), rc);
}
}
} else if (strcmp(ZSTR_VAL(control_oid), LDAP_CONTROL_ASSERT) == 0) {
zval* tmp;
@@ -355,15 +356,19 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
rc = -1;
goto failure;
}
/* ldap_create_assertion_control_value does not reset ld_errno, we need to do it ourselves
See http://www.openldap.org/its/index.cgi/Incoming?id=8674 */
int success = LDAP_SUCCESS;
ldap_set_option(ld, LDAP_OPT_RESULT_CODE, &success);
/* ldap_create_assertion_control_value() allocates memory for control_value.bv_val */
control_value_alloc = 1;
rc = ldap_create_assertion_control_value(ld, ZSTR_VAL(assert), &control_value);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Failed to create assert control value: %s (%d)", ldap_err2string(rc), rc);
control_value = ber_memalloc(sizeof * control_value);
if (control_value == NULL) {
rc = -1;
php_error_docref(NULL, E_WARNING, "Failed to allocate control value");
} else {
/* ldap_create_assertion_control_value does not reset ld_errno, we need to do it ourselves
See http://www.openldap.org/its/index.cgi/Incoming?id=8674 */
int success = LDAP_SUCCESS;
ldap_set_option(ld, LDAP_OPT_RESULT_CODE, &success);
rc = ldap_create_assertion_control_value(ld, ZSTR_VAL(assert), control_value);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Failed to create assert control value: %s (%d)", ldap_err2string(rc), rc);
}
}
zend_string_release(assert);
}
@@ -373,8 +378,9 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
rc = -1;
php_error_docref(NULL, E_WARNING, "Filter missing from control value array");
} else {
ber = ber_alloc_t(LBER_USE_DER);
if (ber == NULL) {
BerElement *vrber = ber_alloc_t(LBER_USE_DER);
control_value = ber_memalloc(sizeof * control_value);
if ((control_value == NULL) || (vrber == NULL)) {
rc = -1;
php_error_docref(NULL, E_WARNING, "Failed to allocate control value");
} else {
@@ -383,11 +389,15 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
rc = -1;
goto failure;
}
if (ldap_put_vrFilter(ber, ZSTR_VAL(tmpstring)) == -1) {
if (ldap_put_vrFilter(vrber, ZSTR_VAL(tmpstring)) == -1) {
ber_free(vrber, 1);
rc = -1;
php_error_docref(NULL, E_WARNING, "Failed to create control value: Bad ValuesReturnFilter: %s", ZSTR_VAL(tmpstring));
} else if (ber_flatten2(ber, &control_value, control_value_alloc) == -1) {
rc = -1;
} else {
if (ber_flatten2(vrber, control_value, 0) == -1) {
rc = -1;
}
ber_free(vrber, 1);
}
}
}
@@ -397,9 +407,10 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
rc = -1;
php_error_docref(NULL, E_WARNING, "Attributes list missing from control value array");
} else {
ber = ber_alloc_t(LBER_USE_DER);
BerElement *ber = ber_alloc_t(LBER_USE_DER);
if (ber == NULL) {
control_value = ber_memalloc(sizeof * control_value);
if ((control_value == NULL) || (ber == NULL)) {
rc = -1;
php_error_docref(NULL, E_WARNING, "Failed to allocate control value");
} else {
@@ -408,8 +419,6 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
num_attribs = zend_hash_num_elements(Z_ARRVAL_P(tmp));
ldap_attrs = safe_emalloc((num_attribs+1), sizeof(char *), 0);
tmpstrings1 = safe_emalloc(num_attribs, sizeof(zend_string*), 0);
num_tmpstrings1 = 0;
for (i = 0; i<num_attribs; i++) {
if ((attr = zend_hash_index_find(Z_ARRVAL_P(tmp), i)) == NULL) {
@@ -418,13 +427,12 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
goto failure;
}
tmpstrings1[num_tmpstrings1] = zval_get_string(attr);
tmpstring = zval_get_string(attr);
if (EG(exception)) {
rc = -1;
goto failure;
}
ldap_attrs[i] = ZSTR_VAL(tmpstrings1[num_tmpstrings1]);
++num_tmpstrings1;
ldap_attrs[i] = ZSTR_VAL(tmpstring);
}
ldap_attrs[num_attribs] = NULL;
@@ -435,7 +443,7 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
php_error_docref(NULL, E_WARNING, "Failed to encode attribute list");
} else {
int err;
err = ber_flatten2(ber, &control_value, control_value_alloc);
err = ber_flatten2(ber, control_value, 0);
if (err < 0) {
rc = -1;
php_error_docref(NULL, E_WARNING, "Failed to encode control value (%d)", err);
@@ -449,10 +457,6 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
num_keys = zend_hash_num_elements(Z_ARRVAL_P(val));
sort_keys = safe_emalloc((num_keys+1), sizeof(LDAPSortKey*), 0);
tmpstrings1 = safe_emalloc(num_keys, sizeof(zend_string*), 0);
tmpstrings2 = safe_emalloc(num_keys, sizeof(zend_string*), 0);
num_tmpstrings1 = 0;
num_tmpstrings2 = 0;
for (i = 0; i<num_keys; i++) {
if ((sortkey = zend_hash_index_find(Z_ARRVAL_P(val), i)) == NULL) {
@@ -467,22 +471,20 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
goto failure;
}
sort_keys[i] = emalloc(sizeof(LDAPSortKey));
tmpstrings1[num_tmpstrings1] = zval_get_string(tmp);
tmpstring = zval_get_string(tmp);
if (EG(exception)) {
rc = -1;
goto failure;
}
sort_keys[i]->attributeType = ZSTR_VAL(tmpstrings1[num_tmpstrings1]);
++num_tmpstrings1;
sort_keys[i]->attributeType = ZSTR_VAL(tmpstring);
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(sortkey), "oid", sizeof("oid") - 1)) != NULL) {
tmpstrings2[num_tmpstrings2] = zval_get_string(tmp);
tmpstring = zval_get_string(tmp);
if (EG(exception)) {
rc = -1;
goto failure;
}
sort_keys[i]->orderingRule = ZSTR_VAL(tmpstrings2[num_tmpstrings2]);
++num_tmpstrings2;
sort_keys[i]->orderingRule = ZSTR_VAL(tmpstring);
} else {
sort_keys[i]->orderingRule = NULL;
}
@@ -494,11 +496,15 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
}
}
sort_keys[num_keys] = NULL;
/* ldap_create_sort_control_value() allocates memory for control_value.bv_val */
control_value_alloc = 1;
rc = ldap_create_sort_control_value(ld, sort_keys, &control_value);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Failed to create sort control value: %s (%d)", ldap_err2string(rc), rc);
control_value = ber_memalloc(sizeof * control_value);
if (control_value == NULL) {
rc = -1;
php_error_docref(NULL, E_WARNING, "Failed to allocate control value");
} else {
rc = ldap_create_sort_control_value(ld, sort_keys, control_value);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Failed to create sort control value: %s (%d)", ldap_err2string(rc), rc);
}
}
} else if (strcmp(ZSTR_VAL(control_oid), LDAP_CONTROL_VLVREQUEST) == 0) {
zval* tmp;
@@ -560,11 +566,15 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
vlvInfo.ldvlv_context = NULL;
}
/* ldap_create_vlv_control_value() allocates memory for control_value.bv_val */
control_value_alloc = 1;
rc = ldap_create_vlv_control_value(ld, &vlvInfo, &control_value);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Failed to create VLV control value: %s (%d)", ldap_err2string(rc), rc);
control_value = ber_memalloc(sizeof * control_value);
if (control_value == NULL) {
rc = -1;
php_error_docref(NULL, E_WARNING, "Failed to allocate control value");
} else {
rc = ldap_create_vlv_control_value(ld, &vlvInfo, control_value);
if (rc != LDAP_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Failed to create VLV control value: %s (%d)", ldap_err2string(rc), rc);
}
}
} else {
php_error_docref(NULL, E_WARNING, "Control OID %s does not expect an array as value", ZSTR_VAL(control_oid));
@@ -573,7 +583,7 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
}
if (rc == LDAP_SUCCESS) {
rc = ldap_control_create(ZSTR_VAL(control_oid), control_iscritical, &control_value, 1, ctrl);
rc = ldap_control_create(ZSTR_VAL(control_oid), control_iscritical, control_value, 1, ctrl);
}
failure:
@@ -581,25 +591,9 @@ failure:
if (tmpstring != NULL) {
zend_string_release(tmpstring);
}
if (tmpstrings1 != NULL) {
int i;
for (i = 0; i < num_tmpstrings1; ++i) {
zend_string_release(tmpstrings1[i]);
}
efree(tmpstrings1);
}
if (tmpstrings2 != NULL) {
int i;
for (i = 0; i < num_tmpstrings2; ++i) {
zend_string_release(tmpstrings2[i]);
}
efree(tmpstrings2);
}
if (control_value.bv_val != NULL && control_value_alloc != 0) {
ber_memfree(control_value.bv_val);
}
if (ber != NULL) {
ber_free(ber, 1);
if (control_value != NULL) {
ber_memfree(control_value);
control_value = NULL;
}
if (ldap_attrs != NULL) {
efree(ldap_attrs);
@@ -1471,7 +1465,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
zend_string *ldap_filter = NULL, *ldap_base_dn = NULL;
char **ldap_attrs = NULL;
ldap_linkdata *ld = NULL;
LDAPMessage *ldap_res = NULL;
LDAPMessage *ldap_res;
LDAPControl **lserverctrls = NULL;
int ldap_attrsonly = 0, ldap_sizelimit = -1, ldap_timelimit = -1, ldap_deref = -1;
int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1;
@@ -1671,11 +1665,6 @@ cleanup_parallel:
&& errno != LDAP_REFERRAL
#endif
) {
/* ldap_res should be freed regardless of return value of ldap_search_ext_s()
* see: https://linux.die.net/man/3/ldap_search_ext_s */
if (ldap_res != NULL) {
ldap_msgfree(ldap_res);
}
php_error_docref(NULL, E_WARNING, "Search: %s", ldap_err2string(errno));
ret = 0;
} else {
@@ -3449,7 +3438,6 @@ PHP_FUNCTION(ldap_parse_result)
/* Reverse -> fall through */
switch (myargcount) {
case 7:
zval_ptr_dtor(serverctrls);
_php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, 0);
case 6:
zval_ptr_dtor(referrals);
@@ -4004,7 +3992,7 @@ PHP_FUNCTION(ldap_control_paged_result)
zval *link;
char *cookie = NULL;
size_t cookie_len = 0;
struct berval lcookie = { 0L, NULL };
struct berval lcookie = { 0, NULL };
ldap_linkdata *ld;
LDAP *ldap;
BerElement *ber = NULL;
@@ -4299,31 +4287,38 @@ PHP_FUNCTION(ldap_exop)
PHP_FUNCTION(ldap_exop_passwd)
{
zval *link, *serverctrls;
struct berval luser = { 0L, NULL };
struct berval loldpw = { 0L, NULL };
struct berval lnewpw = { 0L, NULL };
struct berval lgenpasswd = { 0L, NULL };
LDAPControl *ctrl, **lserverctrls = NULL, *requestctrls[2] = { NULL, NULL };
LDAPMessage* ldap_res = NULL;
struct berval luser, loldpw, lnewpw, lgenpasswd;
LDAPControl **lserverctrls = NULL, **requestctrls = NULL;
LDAPControl *ctrl, **ctrlp;
LDAPMessage* ldap_res;
ldap_linkdata *ld;
int rc, myargcount = ZEND_NUM_ARGS(), msgid, err;
char* errmsg = NULL;
char* errmsg;
luser.bv_len = 0;
loldpw.bv_len = 0;
lnewpw.bv_len = 0;
if (zend_parse_parameters(myargcount, "r|sssz/", &link, &luser.bv_val, &luser.bv_len, &loldpw.bv_val, &loldpw.bv_len, &lnewpw.bv_val, &lnewpw.bv_len, &serverctrls) == FAILURE) {
return;
}
if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
RETVAL_FALSE;
goto cleanup;
RETURN_FALSE;
}
switch (myargcount) {
case 5:
/* ldap_create_passwordpolicy_control() allocates ctrl */
requestctrls = safe_emalloc(2, sizeof(*requestctrls), 0);
*requestctrls = NULL;
ctrlp = requestctrls;
if (ldap_create_passwordpolicy_control(ld->link, &ctrl) == LDAP_SUCCESS) {
requestctrls[0] = ctrl;
*ctrlp = ctrl;
++ctrlp;
}
*ctrlp = NULL;
}
/* asynchronous call to get result and controls */
@@ -4332,45 +4327,31 @@ PHP_FUNCTION(ldap_exop_passwd)
lnewpw.bv_len > 0 ? &lnewpw : NULL,
requestctrls,
NULL, &msgid);
if (requestctrls[0] != NULL) {
ldap_control_free(requestctrls[0]);
}
if (rc != LDAP_SUCCESS ) {
php_error_docref(NULL, E_WARNING, "Passwd modify extended operation failed: %s (%d)", ldap_err2string(rc), rc);
RETVAL_FALSE;
goto cleanup;
RETURN_FALSE;
}
rc = ldap_result(ld->link, msgid, 1 /* LDAP_MSG_ALL */, NULL, &ldap_res);
if ((rc < 0) || !ldap_res) {
rc = _get_lderrno(ld->link);
php_error_docref(NULL, E_WARNING, "Passwd modify extended operation failed: %s (%d)", ldap_err2string(rc), rc);
RETVAL_FALSE;
goto cleanup;
RETURN_FALSE;
}
rc = ldap_parse_passwd(ld->link, ldap_res, &lgenpasswd);
if( rc != LDAP_SUCCESS ) {
php_error_docref(NULL, E_WARNING, "Passwd modify extended operation failed: %s (%d)", ldap_err2string(rc), rc);
RETVAL_FALSE;
goto cleanup;
ldap_msgfree(ldap_res);
RETURN_FALSE;
}
rc = ldap_parse_result(ld->link, ldap_res, &err, NULL, &errmsg, NULL, (myargcount > 4 ? &lserverctrls : NULL), 0);
rc = ldap_parse_result(ld->link, ldap_res, &err, NULL, &errmsg, NULL, (myargcount > 4 ? &lserverctrls : NULL), 1);
if( rc != LDAP_SUCCESS ) {
php_error_docref(NULL, E_WARNING, "Passwd modify extended operation failed: %s (%d)", ldap_err2string(rc), rc);
RETVAL_FALSE;
goto cleanup;
RETURN_FALSE;
}
if (myargcount > 4) {
zval_ptr_dtor(serverctrls);
_php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, 0);
}
/* return */
if (lnewpw.bv_len == 0) {
if (lgenpasswd.bv_len == 0) {
RETVAL_EMPTY_STRING();
@@ -4384,16 +4365,11 @@ PHP_FUNCTION(ldap_exop_passwd)
RETVAL_FALSE;
}
cleanup:
if (lgenpasswd.bv_val != NULL) {
ldap_memfree(lgenpasswd.bv_val);
}
if (ldap_res != NULL) {
ldap_msgfree(ldap_res);
}
if (errmsg != NULL) {
ldap_memfree(errmsg);
if (myargcount > 4) {
_php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, 0);
}
ldap_memfree(lgenpasswd.bv_val);
}
/* }}} */
#endif
+5 -9
View File
@@ -1734,17 +1734,13 @@ mbfl_strimwidth(
mbfl_convert_filter_flush(encoder);
if (pc.status != 0 && mkwidth > 0) {
pc.width += mkwidth;
if (n > 0) {
while (n > 0) {
if ((*encoder->filter_function)(*p++, encoder) < 0) {
break;
}
n--;
while (n > 0) {
if ((*encoder->filter_function)(*p++, encoder) < 0) {
break;
}
mbfl_convert_filter_flush(encoder);
} else if (pc.outwidth > pc.width) {
pc.status++;
n--;
}
mbfl_convert_filter_flush(encoder);
if (pc.status != 1) {
pc.status = 10;
pc.device.pos = pc.endpos;
-20
View File
@@ -1,20 +0,0 @@
--TEST--
Bug #79787 mb_strimwidth does not trim string
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--FILE--
<?php
echo mb_strimwidth("一二三", 0, 4, '.', 'UTF-8')."\n";
echo mb_strimwidth("一二三", 0, 5, '.', 'UTF-8')."\n";
echo mb_strimwidth("一二三", 0, 6, '.', 'UTF-8')."\n";
echo mb_strimwidth("abcdef", 0, 4, '.', 'UTF-8')."\n";
echo mb_strimwidth("abcdef", 0, 5, '.', 'UTF-8')."\n";
echo mb_strimwidth("abcdef", 0, 6, '.', 'UTF-8')."\n";
?>
--EXPECT--
一.
一二.
一二三
abc.
abcd.
abcdef
-3
View File
@@ -223,9 +223,6 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
case ZEND_POST_INC_OBJ:
case ZEND_POST_DEC_OBJ:
case ZEND_ISSET_ISEMPTY_PROP_OBJ:
if (opline->op1_type == IS_CONST) {
LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 1);
}
if (opline->op2_type == IS_CONST) {
LITERAL_INFO(opline->op2.constant, LITERAL_PROPERTY, 1);
}
+64 -13
View File
@@ -31,11 +31,10 @@
#define ACCEL_FILEMAP_NAME "ZendOPcache.SharedMemoryArea"
#define ACCEL_MUTEX_NAME "ZendOPcache.SharedMemoryMutex"
#define ACCEL_FILEMAP_BASE_DEFAULT 0x01000000
#define ACCEL_FILEMAP_BASE "ZendOPcache.MemoryBase"
#define ACCEL_EVENT_SOURCE "Zend OPcache"
/* address of mapping base and address of execute_ex */
#define ACCEL_BASE_POINTER_SIZE (2 * sizeof(void*))
static HANDLE memfile = NULL, memory_mutex = NULL;
static void *mapping_base;
@@ -94,6 +93,28 @@ static char *create_name_with_username(char *name)
return newname;
}
static char *get_mmap_base_file(void)
{
static char windir[MAXPATHLEN+UNLEN + 3 + sizeof("\\\\@") + 1 + 32 + 21];
char *uname;
int l;
uname = php_win32_get_username();
if (!uname) {
return NULL;
}
GetTempPath(MAXPATHLEN, windir);
l = strlen(windir);
if ('\\' == windir[l-1]) {
l--;
}
snprintf(windir + l, sizeof(windir) - l - 1, "\\%s@%s@%.20s@%.32s", ACCEL_FILEMAP_BASE, uname, sapi_module.name, ZCG(system_id));
free(uname);
return windir;
}
void zend_shared_alloc_create_lock(void)
{
memory_mutex = CreateMutex(NULL, FALSE, create_name_with_username(ACCEL_MUTEX_NAME));
@@ -122,20 +143,39 @@ static int zend_shared_alloc_reattach(size_t requested_size, char **error_in)
{
int err;
void *wanted_mapping_base;
char *mmap_base_file = get_mmap_base_file();
FILE *fp = fopen(mmap_base_file, "r");
MEMORY_BASIC_INFORMATION info;
void *execute_ex_base;
int execute_ex_moved;
mapping_base = MapViewOfFileEx(memfile, FILE_MAP_ALL_ACCESS, 0, 0, ACCEL_BASE_POINTER_SIZE, NULL);
if (mapping_base == NULL) {
if (!fp) {
err = GetLastError();
zend_win_error_message(ACCEL_LOG_WARNING, mmap_base_file, err);
zend_win_error_message(ACCEL_LOG_FATAL, "Unable to open base address file", err);
*error_in="fopen";
return ALLOC_FAILURE;
}
if (!fscanf(fp, "%p", &wanted_mapping_base)) {
err = GetLastError();
zend_win_error_message(ACCEL_LOG_FATAL, "Unable to read base address", err);
*error_in="read mapping base";
fclose(fp);
return ALLOC_FAILURE;
}
wanted_mapping_base = ((void**)mapping_base)[0];
execute_ex_base = ((void**)mapping_base)[1];
UnmapViewOfFile(mapping_base);
if (!fscanf(fp, "%p", &execute_ex_base)) {
err = GetLastError();
zend_win_error_message(ACCEL_LOG_FATAL, "Unable to read execute_ex base address", err);
*error_in="read execute_ex base";
fclose(fp);
return ALLOC_FAILURE;
}
fclose(fp);
if (0 > win32_utime(mmap_base_file, NULL)) {
err = GetLastError();
zend_win_error_message(ACCEL_LOG_WARNING, mmap_base_file, err);
}
execute_ex_moved = (void *)execute_ex != execute_ex_base;
@@ -191,7 +231,7 @@ static int zend_shared_alloc_reattach(size_t requested_size, char **error_in)
}
return ALLOC_FAIL_MAPPING;
}
smm_shared_globals = (zend_smm_shared_globals *) ((char*)mapping_base + ACCEL_BASE_POINTER_SIZE);
smm_shared_globals = (zend_smm_shared_globals *) mapping_base;
return SUCCESSFULLY_REATTACHED;
}
@@ -309,12 +349,23 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_
*error_in = "MapViewOfFile";
return ALLOC_FAILURE;
} else {
((void**)mapping_base)[0] = mapping_base;
((void**)mapping_base)[1] = (void*)execute_ex;
char *mmap_base_file = get_mmap_base_file();
void *execute_ex_base = (void *)execute_ex;
FILE *fp = fopen(mmap_base_file, "w");
if (!fp) {
err = GetLastError();
zend_shared_alloc_unlock_win32();
zend_win_error_message(ACCEL_LOG_WARNING, mmap_base_file, err);
zend_win_error_message(ACCEL_LOG_FATAL, "Unable to write base address", err);
return ALLOC_FAILURE;
}
fprintf(fp, "%p\n", mapping_base);
fprintf(fp, "%p\n", execute_ex_base);
fclose(fp);
}
shared_segment->pos = ACCEL_BASE_POINTER_SIZE;
shared_segment->size = requested_size - ACCEL_BASE_POINTER_SIZE;
shared_segment->pos = 0;
shared_segment->size = requested_size;
zend_shared_alloc_unlock_win32();
+1 -1
View File
@@ -870,7 +870,7 @@ int zend_file_cache_script_store(zend_persistent_script *script, int in_shm)
info.checksum = zend_adler32(info.checksum, (unsigned char*)ZSTR_VAL((zend_string*)ZCG(mem)), info.str_size);
#ifdef HAVE_SYS_UIO_H
vec[0].iov_base = (void *)&info;
vec[0].iov_base = &info;
vec[0].iov_len = sizeof(info);
vec[1].iov_base = buf;
vec[1].iov_len = script->size;
-27
View File
@@ -36,33 +36,6 @@
static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value);
void pdo_throw_exception(unsigned int driver_errcode, char *driver_errmsg, pdo_error_type *pdo_error)
{
zval error_info,pdo_exception;
char *pdo_exception_message;
object_init_ex(&pdo_exception, php_pdo_get_exception());
array_init(&error_info);
add_next_index_string(&error_info, *pdo_error);
add_next_index_long(&error_info, driver_errcode);
add_next_index_string(&error_info, driver_errmsg);
spprintf(&pdo_exception_message, 0,"SQLSTATE[%s] [%d] %s",*pdo_error, driver_errcode, driver_errmsg);
zend_update_property(php_pdo_get_exception(), &pdo_exception, "errorInfo", sizeof("errorInfo")-1, &error_info);
zend_update_property_long(php_pdo_get_exception(), &pdo_exception, "code", sizeof("code")-1, driver_errcode);
zend_update_property_string(
php_pdo_get_exception(),
&pdo_exception,
"message",
sizeof("message")-1,
pdo_exception_message
);
efree(pdo_exception_message);
zval_ptr_dtor(&error_info);
zend_throw_exception_object(&pdo_exception);
}
void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp) /* {{{ */
{
pdo_error_type *pdo_err = &dbh->error_code;
-1
View File
@@ -691,7 +691,6 @@ PDO_API void php_pdo_dbh_delref(pdo_dbh_t *dbh);
PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt);
PDO_API void pdo_throw_exception(unsigned int driver_errcode, char *driver_errmsg, pdo_error_type *pdo_error);
#endif /* PHP_PDO_DRIVER_H */
/*
* Local variables:
+2 -1
View File
@@ -103,7 +103,8 @@ int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int lin
if (!dbh->methods) {
PDO_DBG_INF("Throwing exception");
pdo_throw_exception(einfo->errcode, einfo->errmsg, pdo_err);
zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode, "SQLSTATE[%s] [%d] %s",
*pdo_err, einfo->errcode, einfo->errmsg);
}
PDO_DBG_RETURN(einfo->errcode);
-17
View File
@@ -1,17 +0,0 @@
--TEST--
Bug #64705 errorInfo property of PDOException is null when PDO::__construct() fails
--SKIPIF--
<?php
if (!extension_loaded('pdo_mysql')) print 'skip not loaded';
?>
--FILE--
<?php
$dsn = 'mysql:host=DonotExistsHost;dbname=test;user=foo;password=wrongpass';
try {
$pdo = new \PDO($dsn, null, null);
} catch (\PDOException $e) {
var_dump(!empty($e->errorInfo) && is_array($e->errorInfo));
}
?>
--EXPECTF--
bool(true)
+2 -1
View File
@@ -101,7 +101,8 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
}
if (!dbh->methods) {
pdo_throw_exception(einfo->errcode, einfo->errmsg, pdo_err);
zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode, "SQLSTATE[%s] [%d] %s",
*pdo_err, einfo->errcode, einfo->errmsg);
}
return errcode;
-17
View File
@@ -1,17 +0,0 @@
--TEST--
Bug #64705 errorInfo property of PDOException is null when PDO::__construct() fails
--SKIPIF--
<?php
if (!extension_loaded('pdo_pgsql')) print 'skip not loaded';
?>
--FILE--
<?php
$dsn = 'pgsql:host=DonotExistsHost;dbname=test;user=foo;password=wrongpass';
try {
$pdo = new \PDO($dsn, null, null);
} catch (\PDOException $e) {
var_dump(!empty($e->errorInfo) && is_array($e->errorInfo));
}
?>
--EXPECTF--
bool(true)
+2 -1
View File
@@ -76,7 +76,8 @@ int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int li
}
if (!dbh->methods) {
pdo_throw_exception(einfo->errcode, einfo->errmsg, pdo_err);
zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode, "SQLSTATE[%s] [%d] %s",
*pdo_err, einfo->errcode, einfo->errmsg);
}
return einfo->errcode;
+1 -1
View File
@@ -282,7 +282,7 @@ static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno)
str = sqlite3_column_name(S->stmt, colno);
stmt->columns[colno].name = zend_string_init(str, strlen(str), 0);
stmt->columns[colno].maxlen = SIZE_MAX;
stmt->columns[colno].maxlen = 0xffffffff;
stmt->columns[colno].precision = 0;
switch (sqlite3_column_type(S->stmt, colno)) {
+1 -1
View File
@@ -24,7 +24,7 @@ array(6) {
["name"]=>
string(1) "1"
["len"]=>
int(-1)
int(4294967295)
["precision"]=>
int(0)
["pdo_type"]=>
-17
View File
@@ -1,17 +0,0 @@
--TEST--
Bug #64705 errorInfo property of PDOException is null when PDO::__construct() fails
--SKIPIF--
<?php
if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
?>
--FILE--
<?php
$dsn = 'sqlite:./bug64705NonExistingDir/bug64705NonExistingDb';
try {
$pdo = new \PDO($dsn, null, null);
} catch (\PDOException $e) {
var_dump(!empty($e->errorInfo) && is_array($e->errorInfo));
}
?>
--EXPECTF--
bool(true)
Binary file not shown.
-14
View File
@@ -1,14 +0,0 @@
--TEST--
Bug #79797 (Use of freed hash key in the phar_parse_zipfile function)
--SKIPIF--
<?php
if (!extension_loaded('phar')) die('skip phar extension not available');
?>
--INI--
phar.cache_list={PWD}/bug79797.phar
--FILE--
<?php
echo "done\n";
?>
--EXPECT--
done
+1 -1
View File
@@ -705,7 +705,7 @@ foundit:
efree(actual_alias);
}
zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), mydata->alias, mydata->alias_len, mydata);
zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), actual_alias, mydata->alias_len, mydata);
} else {
phar_archive_data *fd_ptr;
@@ -29,12 +29,10 @@ $_SESSION["Blah"] = "Hello World!";
$_SESSION["Foo"] = FALSE;
$_SESSION["Guff"] = 1234567890;
var_dump($_SESSION);
$oldsession = $_SESSION;
var_dump(session_write_close());
session_start();
// the session may have been GC'd or not; we accept either outcome
var_dump($_SESSION === $oldsession || $_SESSION === []);
var_dump($_SESSION);
var_dump(session_destroy());
session_start();
var_dump($_SESSION);
@@ -53,7 +51,14 @@ array(3) {
int(1234567890)
}
bool(true)
bool(true)
array(3) {
["Blah"]=>
string(12) "Hello World!"
["Foo"]=>
bool(false)
["Guff"]=>
int(1234567890)
}
bool(true)
array(0) {
}
+1 -1
View File
@@ -2059,7 +2059,7 @@ static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeade
our fault code with their own handling... Figure this out later
*/
if (use_http_error_status) {
sapi_add_header("HTTP/1.1 500 Internal Server Error", sizeof("HTTP/1.1 500 Internal Server Error")-1, 1);
sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1);
}
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
+8 -7
View File
@@ -197,13 +197,14 @@ PHP_FUNCTION(socket_sendmsg)
res = sendmsg(php_sock->bsd_socket, msghdr, (int)flags);
if (res != -1) {
RETVAL_LONG((zend_long)res);
zend_llist_destroy(allocations);
efree(allocations);
RETURN_LONG((zend_long)res);
} else {
PHP_SOCKET_ERROR(php_sock, "error in sendmsg", errno);
RETVAL_FALSE;
RETURN_FALSE;
}
allocations_dispose(&allocations);
}
PHP_FUNCTION(socket_recvmsg)
@@ -253,6 +254,7 @@ PHP_FUNCTION(socket_recvmsg)
/* we don;t need msghdr anymore; free it */
msghdr = NULL;
allocations_dispose(&allocations);
zval_ptr_dtor(zmsg);
if (!err.has_error) {
@@ -263,15 +265,14 @@ PHP_FUNCTION(socket_recvmsg)
/* no need to destroy/free zres -- it's NULL in this circumstance */
assert(zres == NULL);
}
RETVAL_LONG((zend_long)res);
} else {
SOCKETS_G(last_error) = errno;
php_error_docref(NULL, E_WARNING, "error in recvmsg [%d]: %s",
errno, sockets_strerror(errno));
RETVAL_FALSE;
RETURN_FALSE;
}
allocations_dispose(&allocations);
RETURN_LONG((zend_long)res);
}
PHP_FUNCTION(socket_cmsg_space)
@@ -1,15 +0,0 @@
--TEST--
Error during socket_sendmsg() or socket_recvmsg()
--FILE--
<?php
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_sendmsg($socket, [], -1);
$message = ['controllen' => 1];
socket_recvmsg($socket, $message, -1);
?>
--EXPECTF--
Warning: socket_sendmsg(): error in sendmsg [%d]: %a in %s on line %d
Warning: socket_recvmsg(): error in recvmsg [%d]: %a in %s on line %d
-1
View File
@@ -2885,7 +2885,6 @@ PHP_FUNCTION(sodium_crypto_kx_keypair)
zend_throw_exception(sodium_exception_ce, "internal error", 0);
return;
}
ZSTR_VAL(keypair)[crypto_kx_SECRETKEYBYTES + crypto_kx_PUBLICKEYBYTES] = 0;
RETURN_STR(keypair);
}
+1 -1
View File
@@ -3615,7 +3615,7 @@ PHPAPI int php_array_merge_recursive(HashTable *dest, HashTable *src) /* {{{ */
return 0;
}
} else {
Z_TRY_ADDREF_P(src_zval);
Z_TRY_ADDREF_P(src_entry);
zend_hash_next_index_insert(Z_ARRVAL_P(dest_zval), src_zval);
}
zval_ptr_dtor(&tmp);
+19 -15
View File
@@ -349,8 +349,10 @@ static void _php_dns_free_res(struct __res_state *res) { /* {{{ */
Check DNS records corresponding to a given Internet host name or IP address */
PHP_FUNCTION(dns_check_record)
{
HEADER *hp;
querybuf answer;
#ifndef MAXPACKET
#define MAXPACKET 8192 /* max packet size used internally by BIND */
#endif
u_char ans[MAXPACKET];
char *hostname, *rectype = NULL;
size_t hostname_len, rectype_len = 0;
int type = T_MX, i;
@@ -408,14 +410,14 @@ PHP_FUNCTION(dns_check_record)
res_init();
#endif
i = php_dns_search(handle, hostname, C_IN, type, answer.qb2, sizeof answer);
php_dns_free_handle(handle);
RETVAL_TRUE;
i = php_dns_search(handle, hostname, C_IN, type, ans, sizeof(ans));
if (i < 0) {
RETURN_FALSE;
RETVAL_FALSE;
}
hp = (HEADER *)&answer;
RETURN_BOOL(ntohs(hp->ancount) != 0);
php_dns_free_handle(handle);
}
/* }}} */
@@ -1031,7 +1033,7 @@ PHP_FUNCTION(dns_get_mx)
zval *mx_list, *weight_list = NULL;
int count, qdc;
u_short type, weight;
querybuf answer;
u_char ans[MAXPACKET];
char buf[MAXHOSTNAMELEN];
HEADER *hp;
u_char *cp, *end;
@@ -1074,14 +1076,16 @@ PHP_FUNCTION(dns_get_mx)
res_init();
#endif
i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, answer.qb2, sizeof answer);
i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, (u_char *)&ans, sizeof(ans));
if (i < 0) {
php_dns_free_handle(handle);
RETURN_FALSE;
}
hp = (HEADER *)&answer;
cp = answer.qb2 + HFIXEDSZ;
end = answer.qb2 + i;
if (i > (int)sizeof(ans)) {
i = sizeof(ans);
}
hp = (HEADER *)&ans;
cp = (u_char *)&ans + HFIXEDSZ;
end = (u_char *)&ans +i;
for (qdc = ntohs((unsigned short)hp->qdcount); qdc--; cp += i + QFIXEDSZ) {
if ((i = dn_skipname(cp, end)) < 0 ) {
php_dns_free_handle(handle);
@@ -1103,7 +1107,7 @@ PHP_FUNCTION(dns_get_mx)
continue;
}
GETSHORT(weight, cp);
if ((i = dn_expand(answer.qb2, end, cp, buf, sizeof(buf)-1)) < 0) {
if ((i = dn_expand(ans, end, cp, buf, sizeof(buf)-1)) < 0) {
php_dns_free_handle(handle);
RETURN_FALSE;
}
@@ -1114,7 +1118,7 @@ PHP_FUNCTION(dns_get_mx)
}
}
php_dns_free_handle(handle);
RETURN_BOOL(zend_hash_num_elements(Z_ARRVAL_P(mx_list)) != 0);
RETURN_TRUE;
}
/* }}} */
#endif /* HAVE_FULL_DNS_FUNCS */
+1 -1
View File
@@ -1669,7 +1669,7 @@ PHP_FUNCTION(copy)
Z_PARAM_RESOURCE_EX(zcontext, 1, 0)
ZEND_PARSE_PARAMETERS_END();
if (php_stream_locate_url_wrapper(source, NULL, 0) == &php_plain_files_wrapper && php_check_open_basedir(source)) {
if (php_check_open_basedir(source)) {
RETURN_FALSE;
}
-5
View File
@@ -1496,11 +1496,6 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) {
Z_PARAM_ZVAL_DEREF(info)
ZEND_PARSE_PARAMETERS_END();
if (mode == FROM_PATH && CHECK_NULL_PATH(input, input_len)) {
php_error_docref(NULL, E_WARNING, "Invalid path");
return;
}
if (argc == 2) {
zval_ptr_dtor(info);
array_init(info);
+17 -14
View File
@@ -2610,7 +2610,7 @@ PHP_FUNCTION(substr_replace)
from_idx = len_idx = repl_idx = 0;
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(str), num_index, str_index, tmp_str) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(str), num_index, str_index, tmp_str) {
zend_string *tmp_orig_str;
zend_string *orig_str = zval_get_tmp_string(tmp_str, &tmp_orig_str);
@@ -2823,9 +2823,8 @@ PHP_FUNCTION(chr)
Uppercase the first character of the word in a native string */
static zend_string* php_ucfirst(zend_string *str)
{
const unsigned char ch = ZSTR_VAL(str)[0];
unsigned char r = toupper(ch);
if (r == ch) {
unsigned char r = toupper(ZSTR_VAL(str)[0]);
if (r == ZSTR_VAL(str)[0]) {
return zend_string_copy(str);
} else {
zend_string *s = zend_string_init(ZSTR_VAL(str), ZSTR_LEN(str), 0);
@@ -3063,7 +3062,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
zend_string *key_used;
/* we have to rebuild HashTable with numeric keys */
zend_hash_init(&str_hash, zend_hash_num_elements(pats), NULL, NULL, 0);
ZEND_HASH_FOREACH_KEY_VAL_IND(pats, num_key, str_key, entry) {
ZEND_HASH_FOREACH_KEY_VAL(pats, num_key, str_key, entry) {
if (UNEXPECTED(!str_key)) {
key_used = zend_long_to_str(num_key);
len = ZSTR_LEN(key_used);
@@ -3509,7 +3508,7 @@ PHP_FUNCTION(strtr)
zend_string *str_key, *tmp_str, *replace, *tmp_replace;
zval *entry;
ZEND_HASH_FOREACH_KEY_VAL_IND(pats, num_key, str_key, entry) {
ZEND_HASH_FOREACH_KEY_VAL(pats, num_key, str_key, entry) {
tmp_str = NULL;
if (UNEXPECTED(!str_key)) {
str_key = tmp_str = zend_long_to_str(num_key);
@@ -4269,9 +4268,12 @@ PHPAPI void php_stripslashes(zend_string *str)
*/
static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *subject, zval *result, int case_sensitivity)
{
zval *search_entry;
zval *search_entry,
*replace_entry = NULL;
zend_string *tmp_result,
*tmp_subject_str;
*tmp_subject_str,
*tmp_replace_entry_str = NULL,
*replace_entry_str;
char *replace_value = NULL;
size_t replace_len = 0;
zend_long replace_count = 0;
@@ -4301,16 +4303,14 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
}
/* For each entry in the search array, get the entry */
ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL_P(search), search_entry) {
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(search), search_entry) {
/* Make sure we're dealing with strings. */
zend_string *tmp_search_str;
zend_string *search_str = zval_get_tmp_string(search_entry, &tmp_search_str);
zend_string *replace_entry_str, *tmp_replace_entry_str = NULL;
/* If replace is an array. */
if (Z_TYPE_P(replace) == IS_ARRAY) {
/* Get current entry */
zval *replace_entry = NULL;
while (replace_idx < Z_ARRVAL_P(replace)->nNumUsed) {
replace_entry = &Z_ARRVAL_P(replace)->arData[replace_idx].val;
if (Z_TYPE_P(replace_entry) != IS_UNDEF) {
@@ -4367,12 +4367,15 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
}
} else {
zend_tmp_string_release(tmp_search_str);
zend_tmp_string_release(tmp_replace_entry_str);
continue;
}
zend_tmp_string_release(tmp_search_str);
zend_tmp_string_release(tmp_replace_entry_str);
if (tmp_replace_entry_str) {
zend_string_release_ex(tmp_replace_entry_str, 0);
tmp_replace_entry_str = NULL;
}
if (subject_str == tmp_result) {
zend_string_delref(subject_str);
@@ -4460,7 +4463,7 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit
/* For each subject entry, convert it to string, then perform replacement
and add the result to the return_value array. */
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(subject), num_key, string_key, subject_entry) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(subject), num_key, string_key, subject_entry) {
ZVAL_DEREF(subject_entry);
if (Z_TYPE_P(subject_entry) != IS_ARRAY && Z_TYPE_P(subject_entry) != IS_OBJECT) {
count += php_str_replace_in_subject(search, replace, subject_entry, &result, case_sensitivity);
-33
View File
@@ -1,33 +0,0 @@
--TEST--
Bug #79930: array_merge_recursive() crashes when called with array with single reference
--FILE--
<?php
$a = 'a';
$array = [
'value' => $a . 'b',
];
// Create rc=1 reference.
array_walk($array, function () {});
$m = array_merge_recursive(['value' => 'a'], $array);
var_dump($a, $array, $m);
?>
--EXPECT--
string(1) "a"
array(1) {
["value"]=>
string(2) "ab"
}
array(1) {
["value"]=>
array(2) {
[0]=>
string(1) "a"
[1]=>
string(2) "ab"
}
}
-23
View File
@@ -1,23 +0,0 @@
--TEST--
Bug #79821 (array grow during var_dump)
--FILE--
<?php
foreach (['var_dump', 'debug_zval_dump', 'var_export'] as $output) {
$foo = $bar = [];
for ($i = 0; $i < 3; $i++) {
$foo = [$foo, [&$bar]];
}
ob_start(function (string $buffer) use (&$bar) {
$bar[][] = null;
return '';
}, 64);
$output($foo[0]);
ob_end_clean();
}
echo "OK\n";
?>
--EXPECT--
OK
@@ -1,5 +1,11 @@
--TEST--
Test realpath() with relative paths
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip no symlinks on Windows');
}
?>
--FILE--
<?php
$file_path = dirname(__FILE__);
-9
View File
@@ -1,9 +0,0 @@
--TEST--
Bug #79877 (getimagesize function silently truncates after a null byte)
--FILE--
<?php
var_dump(getimagesize("/tmp/a.png\0xx"));
?>
--EXPECTF--
Warning: getimagesize(): Invalid path in %s on line %d
NULL
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Test invalid bindto
--FILE--
<?php
$ctx = stream_context_create([
'socket' => [
'bindto' => 'invalid',
],
]);
$fp = stream_socket_client(
'tcp://www.' . str_repeat('x', 100) . '.com:80',
$errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ctx
);
?>
--EXPECTF--
Warning: stream_socket_client(): unable to connect to tcp://%s:80 (Failed to parse address "invalid") in %s on line %d
+9 -13
View File
@@ -10,19 +10,15 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
?>
--FILE--
<?php
$domains = array(
'mx1.tests.php.net',
'mx2.tests.php.net',
'qa.php.net',
);
foreach ($domains as $domain) {
$result = getmxrr($domain, $hosts, $weights);
echo "Result: " . ($result ? "true" : "false")
. ", hosts: " . count( $hosts )
. ", weights: " . count( $weights ) . "\n";
$domains = array( 'mx1.tests.php.net', 'mx2.tests.php.net' );
foreach ( $domains as $domain )
{
if ( getmxrr( $domain, $hosts, $weights ) )
{
echo "Hosts: " . count( $hosts ) . ", weights: " . count( $weights ) . "\n";
}
}
?>
--EXPECT--
Result: true, hosts: 1, weights: 1
Result: true, hosts: 2, weights: 2
Result: false, hosts: 0, weights: 0
Hosts: 1, weights: 1
Hosts: 2, weights: 2
-15
View File
@@ -1,15 +0,0 @@
--TEST--
Bug #70362 (Can't copy() large 'data://' with open_basedir)
--INI--
open_basedir=.
--FILE--
<?php
$temp = tempnam(__DIR__, 'test');
$data = str_repeat('0', 4096);
$data = 'data://plain/text;base64,' . base64_encode($data);
var_dump(copy($data, $temp));
echo file_get_contents($temp);
?>
--EXPECT--
bool(true)
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-10
View File
@@ -1,10 +0,0 @@
--TEST--
Bug #79951: Memory leak in str_replace of empty string
--FILE--
<?php
var_dump(str_replace([""], [1000], "foo"));
?>
--EXPECT--
string(3) "foo"
+16 -29
View File
@@ -117,26 +117,21 @@ again:
break;
case IS_ARRAY:
myht = Z_ARRVAL_P(struc);
if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) {
if (level > 1) {
if (GC_IS_RECURSIVE(myht)) {
PUTS("*RECURSION*\n");
return;
}
GC_PROTECT_RECURSION(myht);
if (level > 1 && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
if (GC_IS_RECURSIVE(myht)) {
PUTS("*RECURSION*\n");
return;
}
GC_ADDREF(myht);
GC_PROTECT_RECURSION(myht);
}
count = zend_array_count(myht);
php_printf("%sarray(%d) {\n", COMMON, count);
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, num, key, val) {
php_array_element_dump(val, num, key, level);
} ZEND_HASH_FOREACH_END();
if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) {
if (level > 1) {
GC_UNPROTECT_RECURSION(myht);
}
GC_DELREF(myht);
if (level > 1 && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(myht);
}
if (level > 1) {
php_printf("%*c", level-1, ' ');
@@ -289,26 +284,20 @@ again:
break;
case IS_ARRAY:
myht = Z_ARRVAL_P(struc);
if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) {
if (level > 1) {
if (GC_IS_RECURSIVE(myht)) {
PUTS("*RECURSION*\n");
return;
}
GC_PROTECT_RECURSION(myht);
if (level > 1 && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
if (GC_IS_RECURSIVE(myht)) {
PUTS("*RECURSION*\n");
return;
}
GC_ADDREF(myht);
GC_PROTECT_RECURSION(myht);
}
count = zend_array_count(myht);
php_printf("%sarray(%d) refcount(%u){\n", COMMON, count, Z_REFCOUNTED_P(struc) ? Z_REFCOUNT_P(struc) - 1 : 1);
php_printf("%sarray(%d) refcount(%u){\n", COMMON, count, Z_REFCOUNTED_P(struc) ? Z_REFCOUNT_P(struc) : 1);
ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, val) {
zval_array_element_dump(val, index, key, level);
} ZEND_HASH_FOREACH_END();
if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) {
if (level > 1) {
GC_UNPROTECT_RECURSION(myht);
}
GC_DELREF(myht);
if (level > 1 && !(GC_FLAGS(myht) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(myht);
}
if (is_temp) {
zend_hash_destroy(myht);
@@ -507,7 +496,6 @@ again:
zend_error(E_WARNING, "var_export does not handle circular references");
return;
}
GC_ADDREF(myht);
GC_PROTECT_RECURSION(myht);
}
if (level > 1) {
@@ -520,7 +508,6 @@ again:
} ZEND_HASH_FOREACH_END();
if (!(GC_FLAGS(myht) & GC_IMMUTABLE)) {
GC_UNPROTECT_RECURSION(myht);
GC_DELREF(myht);
}
if (level > 1) {
buffer_append_spaces(buf, level - 1);
-17
View File
@@ -1,17 +0,0 @@
--TEST--
Bug #79922 (Crash after multiple calls to xml_parser_free())
--SKIPIF--
<?php
if (!extension_loaded('xml')) die('skip xml extension not available');
?>
--FILE--
<?php
$c=xml_parser_create_ns();
$a=xml_parser_free($c);
$a=xml_parser_free($c);
$c=0;
var_dump($a);
?>
--EXPECTF--
Warning: xml_parser_free(): supplied resource is not a valid XML Parser resource in %s on line %d
bool(false)
+2 -2
View File
@@ -1132,7 +1132,7 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp
XML_SetUserData(parser->parser, parser);
RETVAL_RES(zend_register_resource(parser, le_xml_parser));
ZVAL_COPY_VALUE(&parser->index, return_value);
ZVAL_COPY(&parser->index, return_value);
}
/* }}} */
@@ -1559,7 +1559,7 @@ PHP_FUNCTION(xml_parser_free)
RETURN_FALSE;
}
if (zend_list_close(Z_RES(parser->index)) == FAILURE) {
if (zend_list_delete(Z_RES(parser->index)) == FAILURE) {
RETURN_FALSE;
}
+3 -3
View File
@@ -2,7 +2,7 @@
/* edit configure.ac to change version number */
#define PHP_MAJOR_VERSION 7
#define PHP_MINOR_VERSION 3
#define PHP_RELEASE_VERSION 22
#define PHP_RELEASE_VERSION 20
#define PHP_EXTRA_VERSION "RC1"
#define PHP_VERSION "7.3.22RC1"
#define PHP_VERSION_ID 70322
#define PHP_VERSION "7.3.20RC1"
#define PHP_VERSION_ID 70320
+4 -10
View File
@@ -187,14 +187,11 @@ PHPAPI char *php_ctime_r(const time_t *clock, char *buf)
local_lock(CTIME_R);
tmp = ctime(clock);
if (tmp) {
strcpy(buf, tmp);
tmp = buf;
}
strcpy(buf, tmp);
local_unlock(CTIME_R);
return tmp;
return buf;
}
#endif
@@ -208,14 +205,11 @@ PHPAPI char *php_asctime_r(const struct tm *tm, char *buf)
local_lock(ASCTIME_R);
tmp = asctime(tm);
if (tmp) {
strcpy(buf, tmp);
tmp = buf;
}
strcpy(buf, tmp);
local_unlock(ASCTIME_R);
return tmp;
return buf;
}
#endif
-4
View File
@@ -744,10 +744,6 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
return -1;
}
bindto = parse_ip_address_ex(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval), &bindport, xparam->want_errortext, &xparam->outputs.error_text);
if (bindto == NULL) {
efree(host);
return -1;
}
}
#ifdef SO_BROADCAST
+1 -1
View File
@@ -362,7 +362,7 @@ static void php_apache_sapi_log_message_ex(char *msg, request_rec *r)
static double php_apache_sapi_get_request_time(void)
{
php_struct *ctx = SG(server_context);
return ((double) ctx->r->request_time) / 1000000.0;
return ((double) apr_time_as_msec(ctx->r->request_time)) / 1000.0;
}
extern zend_module_entry php_apache_module;
+2 -11
View File
@@ -365,13 +365,7 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c
static const char *get_mime_type(const php_cli_server *server, const char *ext, size_t ext_len) /* {{{ */
{
char *ret;
ALLOCA_FLAG(use_heap)
char *ext_lower = do_alloca(ext_len + 1, use_heap);
zend_str_tolower_copy(ext_lower, ext, ext_len);
ret = zend_hash_str_find_ptr(&server->extension_mime_types, ext_lower, ext_len);
free_alloca(ext_lower, use_heap);
return (const char*)ret;
return (const char*)zend_hash_str_find_ptr(&server->extension_mime_types, ext, ext_len);
} /* }}} */
PHP_FUNCTION(apache_request_headers) /* {{{ */
@@ -2146,12 +2140,9 @@ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server
static int php_cli_server_dispatch(php_cli_server *server, php_cli_server_client *client) /* {{{ */
{
int is_static_file = 0;
const char *ext = client->request.ext;
SG(server_context) = client;
if (client->request.ext_len != 3
|| (ext[0] != 'p' && ext[0] != 'P') || (ext[1] != 'h' && ext[1] != 'H') || (ext[2] != 'p' && ext[2] != 'P')
|| !client->request.path_translated) {
if (client->request.ext_len != 3 || memcmp(client->request.ext, "php", 3) || !client->request.path_translated) {
is_static_file = 1;
}
+3 -3
View File
@@ -61,7 +61,7 @@
#include "lscriu.c"
#endif
#define SAPI_LSAPI_MAX_HEADER_LENGTH LSAPI_RESP_HTTP_HEADER_MAX
#define SAPI_LSAPI_MAX_HEADER_LENGTH 2048
/* Key for each cache entry is dirname(PATH_TRANSLATED).
*
@@ -610,7 +610,7 @@ static int sapi_lsapi_activate()
static sapi_module_struct lsapi_sapi_module =
{
"litespeed",
"LiteSpeed V7.7",
"LiteSpeed V7.6",
php_lsapi_startup, /* startup */
php_module_shutdown_wrapper, /* shutdown */
@@ -1752,7 +1752,7 @@ PHP_FUNCTION(litespeed_response_headers)
if ( h->header_len > 0 ) {
p = strchr( h->header, ':' );
len = p - h->header;
if (p && len > 0 && len < LSAPI_RESP_HTTP_HEADER_MAX) {
if (( p )&&( len > 0 )) {
memmove( headerBuf, h->header, len );
while( len > 0 && (isspace( headerBuf[len-1])) ) {
--len;
+11 -225
View File
@@ -126,7 +126,7 @@ enum
LSAPI_STATE_ACCEPTING,
};
typedef struct lsapi_child_status
typedef struct _lsapi_child_status
{
int m_pid;
long m_tmStart;
@@ -790,10 +790,10 @@ static int lsapi_load_lve_lib(void)
int uid = getuid();
if ( uid )
{
if (setreuid( s_uid, uid )) {};
setreuid( s_uid, uid );
if ( !(*fp_lve_is_available)() )
s_enable_lve = 0;
if (setreuid( uid, s_uid )) {};
setreuid( uid, s_uid );
}
}
}
@@ -898,7 +898,7 @@ static int LSAPI_perror_r( LSAPI_Request * pReq, const char * pErr1, const char
if ( pReq )
LSAPI_Write_Stderr_r( pReq, achError, n );
else
if (write( STDERR_FILENO, achError, n )) {};
write( STDERR_FILENO, achError, n );
return 0;
}
@@ -2622,8 +2622,7 @@ int LSAPI_ParseSockAddr( const char * pBind, struct sockaddr * pAddr )
while( isspace( *pBind ) )
++pBind;
strncpy(achAddr, pBind, 255);
achAddr[255] = 0;
strncpy( achAddr, pBind, 256 );
switch( *p )
{
@@ -2776,9 +2775,6 @@ int LSAPI_Init_Prefork_Server( int max_children, fn_select_t fp, int avoidFork )
g_prefork_server->m_iMaxIdleChildren = 1;
g_prefork_server->m_iChildrenMaxIdleTime = 300;
g_prefork_server->m_iMaxReqProcessTime = 3600;
setsid();
return 0;
}
@@ -2834,11 +2830,6 @@ static lsapi_child_status * find_child_status( int pid )
{
if ( pStatus->m_pid == pid )
{
if (pid == 0)
{
memset(pStatus, 0, sizeof( *pStatus ) );
pStatus->m_pid = -1;
}
if ( pStatus + 1 > g_prefork_server->m_pChildrenStatusCur )
g_prefork_server->m_pChildrenStatusCur = pStatus + 1;
return pStatus;
@@ -2937,10 +2928,7 @@ static void lsapi_sigchild( int signal )
static int lsapi_init_children_status(void)
{
int size = 4096;
int max_children;
if (g_prefork_server->m_pChildrenStatus)
return 0;
max_children = g_prefork_server->m_iMaxChildren
int max_children = g_prefork_server->m_iMaxChildren
+ g_prefork_server->m_iExtraChildren;
char * pBuf;
@@ -2961,8 +2949,6 @@ static int lsapi_init_children_status(void)
s_accepting_workers = s_busy_workers + 1;
s_global_counter = s_accepting_workers + 1;
s_avail_pages = (size_t *)(s_global_counter + 1);
setsid();
return 0;
}
@@ -3132,6 +3118,8 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
lsapi_init_children_status();
setsid();
act.sa_flags = 0;
act.sa_handler = lsapi_sigchild;
sigemptyset(&(act.sa_mask));
@@ -3153,7 +3141,7 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
perror( "Can't set signals" );
return -1;
}
s_stop = 0;
while( !s_stop )
{
if (s_proc_group_timer_cb != NULL) {
@@ -3231,6 +3219,8 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
{
wait_secs = 0;
child_status = find_child_status( 0 );
if ( child_status )
memset( child_status, 0, sizeof( *child_status ) );
sigemptyset( &mask );
sigaddset( &mask, SIGCHLD );
@@ -3322,210 +3312,6 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
}
static struct sigaction old_term, old_quit, old_int,
old_usr1, old_child;
int LSAPI_Postfork_Child(LSAPI_Request * pReq)
{
int max_children = g_prefork_server->m_iMaxChildren;
s_pid = getpid();
__sync_lock_test_and_set(&pReq->child_status->m_pid, s_pid);
s_worker_status = pReq->child_status;
setsid();
g_prefork_server = NULL;
s_ppid = getppid();
s_req_processed = 0;
s_proc_group_timer_cb = NULL;
if (pthread_atfork_func)
(*pthread_atfork_func)(NULL, NULL, set_skip_write);
__sync_lock_test_and_set(&s_worker_status->m_state,
LSAPI_STATE_CONNECTED);
if (s_busy_workers)
__sync_add_and_fetch(s_busy_workers, 1);
lsapi_set_nblock( pReq->m_fd, 0 );
//keep it open if busy_count is used.
if (s_busy_workers
&& *s_busy_workers > (max_children >> 1))
s_keepListener = 1;
if ((s_uid == 0 || !s_keepListener || !is_enough_free_mem())
&& pReq->m_fdListen != -1 )
{
close(pReq->m_fdListen);
pReq->m_fdListen = -1;
}
//init_conn_key( pReq->m_fd );
lsapi_notify_pid(pReq->m_fd);
s_notified_pid = 1;
//if ( s_accept_notify )
// return notify_req_received( pReq->m_fd );
return 0;
}
int LSAPI_Postfork_Parent(LSAPI_Request * pReq)
{
++g_prefork_server->m_iCurChildren;
if (pReq->child_status)
{
time_t curTime = time( NULL );
pReq->child_status->m_tmWaitBegin = curTime;
pReq->child_status->m_tmStart = curTime;
}
close(pReq->m_fd);
pReq->m_fd = -1;
return 0;
}
int LSAPI_Accept_Before_Fork(LSAPI_Request * pReq)
{
time_t lastTime = 0;
time_t curTime = 0;
fd_set readfds;
struct timeval timeout;
int wait_secs = 0;
int ret = 0;
lsapi_prefork_server * pServer = g_prefork_server;
struct sigaction act;
lsapi_init_children_status();
act.sa_flags = 0;
act.sa_handler = lsapi_sigchild;
sigemptyset(&(act.sa_mask));
if (sigaction(SIGCHLD, &act, &old_child))
{
perror( "Can't set signal handler for SIGCHILD" );
return -1;
}
/* Set up handler to kill children upon exit */
act.sa_flags = 0;
act.sa_handler = lsapi_cleanup;
sigemptyset(&(act.sa_mask));
if (sigaction(SIGTERM, &act, &old_term) ||
sigaction(SIGINT, &act, &old_int ) ||
sigaction(SIGUSR1, &act, &old_usr1) ||
sigaction(SIGQUIT, &act, &old_quit))
{
perror( "Can't set signals" );
return -1;
}
s_stop = 0;
pReq->m_reqState = 0;
while(!s_stop)
{
if (s_proc_group_timer_cb != NULL) {
s_proc_group_timer_cb(&s_ignore_pid);
}
curTime = time(NULL);
if (curTime != lastTime)
{
lastTime = curTime;
if (lsapi_parent_dead())
break;
lsapi_check_child_status(curTime);
if (pServer->m_iServerMaxIdle)
{
if (pServer->m_iCurChildren <= 0)
{
++wait_secs;
if ( wait_secs > pServer->m_iServerMaxIdle )
return -1;
}
else
wait_secs = 0;
}
}
#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__gnu_linux__)
*s_avail_pages = sysconf(_SC_AVPHYS_PAGES);
// lsapi_log("Memory total: %zd, free: %zd, free %%%zd\n",
// s_total_pages, *s_avail_pages, *s_avail_pages * 100 / s_total_pages);
#endif
FD_ZERO(&readfds);
FD_SET(pServer->m_fd, &readfds);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
ret = (*g_fnSelect)(pServer->m_fd+1, &readfds, NULL, NULL, &timeout);
if (ret == 1 )
{
int accepting = 0;
if (s_accepting_workers)
accepting = __sync_add_and_fetch(s_accepting_workers, 0);
if (pServer->m_iCurChildren > 0
&& accepting > 0)
{
usleep( 400);
while(accepting-- > 0)
sched_yield();
continue;
}
}
else if (ret == -1)
{
if (errno == EINTR)
continue;
/* perror( "select()" ); */
break;
}
else
{
continue;
}
if (pServer->m_iCurChildren >=
pServer->m_iMaxChildren + pServer->m_iExtraChildren)
{
lsapi_log("Reached max children process limit: %d, extra: %d,"
" current: %d, busy: %d, please increase LSAPI_CHILDREN.\n",
pServer->m_iMaxChildren, pServer->m_iExtraChildren,
pServer->m_iCurChildren,
s_busy_workers ? *s_busy_workers : -1);
usleep(100000);
continue;
}
pReq->m_fd = lsapi_accept(pServer->m_fd);
if (pReq->m_fd != -1)
{
wait_secs = 0;
pReq->child_status = find_child_status(0);
ret = 0;
break;
}
else
{
if ((errno == EINTR) || (errno == EAGAIN))
continue;
perror( "accept() failed" );
ret = -1;
break;
}
}
sigaction(SIGCHLD, &old_child, 0);
sigaction(SIGTERM, &old_term, 0);
sigaction(SIGQUIT, &old_quit, 0);
sigaction(SIGINT, &old_int, 0);
sigaction(SIGUSR1, &old_usr1, 0);
return ret;
}
void lsapi_perror( const char * pMessage, int err_no )
{
lsapi_log("%s, errno: %d (%s)\n", pMessage, err_no,
+1 -8
View File
@@ -70,7 +70,7 @@ struct LSAPI_key_value_pair
int valLen;
};
struct lsapi_child_status;
#define LSAPI_MAX_RESP_HEADERS 1000
typedef struct lsapi_request
@@ -91,7 +91,6 @@ typedef struct lsapi_request
char * m_pRespHeaderBuf;
char * m_pRespHeaderBufEnd;
char * m_pRespHeaderBufPos;
struct lsapi_child_status * child_status;
struct iovec * m_pIovec;
@@ -396,12 +395,6 @@ void LSAPI_Register_Pgrp_Timer_Callback(LSAPI_On_Timer_pf);
int LSAPI_Inc_Req_Processed(int cnt);
int LSAPI_Accept_Before_Fork(LSAPI_Request * pReq);
int LSAPI_Postfork_Child(LSAPI_Request * pReq);
int LSAPI_Postfork_Parent(LSAPI_Request * pReq);
#define LSAPI_LOG_LEVEL_BITS 0xff
#define LSAPI_LOG_FLAG_NONE 0
#define LSAPI_LOG_FLAG_DEBUG 1
-1
View File
@@ -1,5 +1,4 @@
#!/bin/bash
set -ex
if [[ "$ENABLE_MAINTAINER_ZTS" == 1 ]]; then
TS="--enable-maintainer-zts";
else
+1 -1
View File
@@ -9,7 +9,7 @@
#define NTDDI_VERSION 0x06010000
/* Default PHP / PEAR directories */
#define PHP_CONFIG_FILE_PATH ""
#define PHP_CONFIG_FILE_PATH (getenv("SystemRoot")?getenv("SystemRoot"):"")
#define CONFIGURATION_FILE_PATH "php.ini"
#define PEAR_INSTALLDIR "@PREFIX@\\pear"
#define PHP_BINDIR "@PREFIX@"
Loaded 100 of 101 files, more files were not shown because too many files have changed in this diff. Show more