mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-23 00:45:43 +00:00
Compare commits
44
Commits
php-7.3.21
...
php-7.3.22
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c15e2532a2 | ||
|
|
3edc6eea84 | ||
|
|
1ae80f8c92 | ||
|
|
f6d7af21a3 | ||
|
|
2fe2e5b48f | ||
|
|
2fa4ca95db | ||
|
|
dc108feab8 | ||
|
|
9d9dffe60a | ||
|
|
07cb2755be | ||
|
|
4723bd4ffa | ||
|
|
a06eed0c0e | ||
|
|
0af3f49312 | ||
|
|
5be670265b | ||
|
|
06ade15528 | ||
|
|
6a1bd57df5 | ||
|
|
da786a22af | ||
|
|
12db8b90a7 | ||
|
|
c4677af67e | ||
|
|
4221e000b1 | ||
|
|
6b8ffdbdeb | ||
|
|
f3a43e85e7 | ||
|
|
fdf6b0fefe | ||
|
|
17d64af186 | ||
|
|
07aeb9171d | ||
|
|
5b29af5c78 | ||
|
|
ff577b04c0 | ||
|
|
7355ab8176 | ||
|
|
1e0bc6e30f | ||
|
|
d95c53834c | ||
|
|
57ad5b3432 | ||
|
|
99c48a2477 | ||
|
|
e767ca60a0 | ||
|
|
0b8c83f593 | ||
|
|
9a744c66e7 | ||
|
|
c756f82c02 | ||
|
|
efe6d96b45 | ||
|
|
1aeff522b8 | ||
|
|
d5b59b4303 | ||
|
|
6f18d7e2f9 | ||
|
|
874284d1c9 | ||
|
|
c39f5fe94e | ||
|
|
15efb96d4c | ||
|
|
6b99a8be4d | ||
|
|
2c0a6977dd |
No files matched your search
@@ -1,12 +1,58 @@
|
||||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 7.3.21
|
||||
03 Sep 2020, PHP 7.3.22
|
||||
|
||||
- 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).
|
||||
@@ -30,13 +76,17 @@ PHP NEWS
|
||||
- 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)
|
||||
|
||||
?? ??? ????, PHP 7.3.20
|
||||
09 Jul 2020, PHP 7.3.20
|
||||
|
||||
- Core:
|
||||
. Fixed bug #79650 (php-win.exe 100% cpu lockup). (cmb)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
--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
|
||||
@@ -0,0 +1,29 @@
|
||||
--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
-1
@@ -20,7 +20,7 @@
|
||||
#ifndef ZEND_H
|
||||
#define ZEND_H
|
||||
|
||||
#define ZEND_VERSION "3.3.21-dev"
|
||||
#define ZEND_VERSION "3.3.22"
|
||||
|
||||
#define ZEND_ENGINE_3
|
||||
|
||||
|
||||
@@ -882,9 +882,7 @@ repeat:
|
||||
case IS_OBJECT:
|
||||
if (Z_TYPE(val_free) == IS_UNDEF) {
|
||||
if (Z_OBJ_HT_P(val)->get) {
|
||||
zval rv;
|
||||
val = Z_OBJ_HT_P(val)->get(val, &rv);
|
||||
ZVAL_COPY_VALUE(&val_free, val);
|
||||
val = Z_OBJ_HT_P(val)->get(val, &val_free);
|
||||
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) {
|
||||
|
||||
+350
-349
File diff suppressed because it is too large.
Load diff
@@ -1112,6 +1112,7 @@ 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;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* Generated by re2c 1.0.1 */
|
||||
#line 3 "Zend/zend_language_scanner_defs.h"
|
||||
/* Generated by re2c 1.3 */
|
||||
|
||||
enum YYCONDTYPE {
|
||||
yycST_IN_SCRIPTING,
|
||||
|
||||
+19
-2
@@ -845,6 +845,7 @@ 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) {
|
||||
@@ -867,7 +868,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
|
||||
tmp = do_alloca(len+1, use_heap);
|
||||
memcpy(tmp, path, len+1);
|
||||
|
||||
retry:
|
||||
retry_reparse_tag_cloud:
|
||||
if(save &&
|
||||
!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
|
||||
(dataw.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
||||
@@ -928,7 +929,7 @@ retry:
|
||||
dataw.dwFileAttributes = fileInformation.dwFileAttributes;
|
||||
CloseHandle(hLink);
|
||||
(*ll)--;
|
||||
goto retry;
|
||||
goto retry_reparse_tag_cloud;
|
||||
}
|
||||
free_alloca(tmp, use_heap);
|
||||
CloseHandle(hLink);
|
||||
@@ -1075,6 +1076,22 @@ retry:
|
||||
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
@@ -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
|
||||
|
||||
+2
-2
@@ -107,8 +107,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||
|
||||
PHP_MAJOR_VERSION=7
|
||||
PHP_MINOR_VERSION=3
|
||||
PHP_RELEASE_VERSION=21
|
||||
PHP_EXTRA_VERSION="-dev"
|
||||
PHP_RELEASE_VERSION=22
|
||||
PHP_EXTRA_VERSION=""
|
||||
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`
|
||||
|
||||
|
||||
@@ -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) && !cached) {
|
||||
if (COMG(autoreg_on)) {
|
||||
php_com_import_typelib(TL, mode, obj->code_page);
|
||||
}
|
||||
|
||||
@@ -838,9 +838,7 @@ PHP_FUNCTION(com_load_typelib)
|
||||
php_com_initialize();
|
||||
pTL = php_com_load_typelib_via_cache(name, codepage, &cached);
|
||||
if (pTL) {
|
||||
if (cached) {
|
||||
RETVAL_TRUE;
|
||||
} else if (php_com_import_typelib(pTL, cs ? CONST_CS : 0, codepage) == SUCCESS) {
|
||||
if (php_com_import_typelib(pTL, cs ? CONST_CS : 0, codepage) == SUCCESS) {
|
||||
RETVAL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -252,9 +252,7 @@ static PHP_INI_MH(OnTypeLibFileUpdate)
|
||||
}
|
||||
|
||||
if ((pTL = php_com_load_typelib_via_cache(typelib_name, COMG(code_page), &cached)) != NULL) {
|
||||
if (!cached) {
|
||||
php_com_import_typelib(pTL, mode, COMG(code_page));
|
||||
}
|
||||
php_com_import_typelib(pTL, mode, COMG(code_page));
|
||||
ITypeLib_Release(pTL);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-10
@@ -66,7 +66,7 @@ typedef unsigned char uchar;
|
||||
|
||||
#define EFREE_IF(ptr) if (ptr) efree(ptr)
|
||||
|
||||
#define MAX_IFD_NESTING_LEVEL 150
|
||||
#define MAX_IFD_NESTING_LEVEL 200
|
||||
|
||||
/* {{{ arginfo */
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_exif_tagname, 0)
|
||||
@@ -3173,6 +3173,23 @@ 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;
|
||||
@@ -3203,15 +3220,6 @@ 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.
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,17 @@
|
||||
--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===
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+98
-104
@@ -167,15 +167,17 @@ 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;
|
||||
struct berval lcookie = { 0L, NULL };
|
||||
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);
|
||||
@@ -184,6 +186,10 @@ 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;
|
||||
@@ -302,27 +308,23 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
|
||||
control_iscritical = 0;
|
||||
}
|
||||
|
||||
struct berval *control_value = NULL;
|
||||
BerElement *ber = NULL;
|
||||
struct berval control_value = { 0L, NULL };
|
||||
int control_value_alloc = 0;
|
||||
|
||||
if ((val = zend_hash_str_find(Z_ARRVAL_P(array), "value", sizeof("value") - 1)) != NULL) {
|
||||
if (Z_TYPE_P(val) != IS_ARRAY) {
|
||||
control_value = ber_memalloc(sizeof * control_value);
|
||||
if (control_value == NULL) {
|
||||
tmpstring = zval_get_string(val);
|
||||
if (EG(exception)) {
|
||||
rc = -1;
|
||||
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);
|
||||
goto failure;
|
||||
}
|
||||
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 = { 0, NULL };
|
||||
struct berval cookie = { 0L, NULL };
|
||||
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(val), "size", sizeof("size") - 1)) != NULL) {
|
||||
pagesize = zval_get_long(tmp);
|
||||
}
|
||||
@@ -335,15 +337,11 @@ 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
/* 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);
|
||||
}
|
||||
} else if (strcmp(ZSTR_VAL(control_oid), LDAP_CONTROL_ASSERT) == 0) {
|
||||
zval* tmp;
|
||||
@@ -357,19 +355,15 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
|
||||
rc = -1;
|
||||
goto failure;
|
||||
}
|
||||
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);
|
||||
}
|
||||
/* 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);
|
||||
}
|
||||
zend_string_release(assert);
|
||||
}
|
||||
@@ -379,9 +373,8 @@ 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 {
|
||||
BerElement *vrber = ber_alloc_t(LBER_USE_DER);
|
||||
control_value = ber_memalloc(sizeof * control_value);
|
||||
if ((control_value == NULL) || (vrber == NULL)) {
|
||||
ber = ber_alloc_t(LBER_USE_DER);
|
||||
if (ber == NULL) {
|
||||
rc = -1;
|
||||
php_error_docref(NULL, E_WARNING, "Failed to allocate control value");
|
||||
} else {
|
||||
@@ -390,14 +383,11 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
|
||||
rc = -1;
|
||||
goto failure;
|
||||
}
|
||||
if (ldap_put_vrFilter(vrber, ZSTR_VAL(tmpstring)) == -1) {
|
||||
ber_free(vrber, 1);
|
||||
if (ldap_put_vrFilter(ber, ZSTR_VAL(tmpstring)) == -1) {
|
||||
rc = -1;
|
||||
php_error_docref(NULL, E_WARNING, "Failed to create control value: Bad ValuesReturnFilter: %s", ZSTR_VAL(tmpstring));
|
||||
} else {
|
||||
if (ber_flatten2(vrber, control_value, 0) == -1) {
|
||||
rc = -1;
|
||||
}
|
||||
} else if (ber_flatten2(ber, &control_value, control_value_alloc) == -1) {
|
||||
rc = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -407,10 +397,9 @@ 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 {
|
||||
BerElement *ber = ber_alloc_t(LBER_USE_DER);
|
||||
ber = ber_alloc_t(LBER_USE_DER);
|
||||
|
||||
control_value = ber_memalloc(sizeof * control_value);
|
||||
if ((control_value == NULL) || (ber == NULL)) {
|
||||
if (ber == NULL) {
|
||||
rc = -1;
|
||||
php_error_docref(NULL, E_WARNING, "Failed to allocate control value");
|
||||
} else {
|
||||
@@ -446,7 +435,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, 0);
|
||||
err = ber_flatten2(ber, &control_value, control_value_alloc);
|
||||
if (err < 0) {
|
||||
rc = -1;
|
||||
php_error_docref(NULL, E_WARNING, "Failed to encode control value (%d)", err);
|
||||
@@ -505,15 +494,11 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
|
||||
}
|
||||
}
|
||||
sort_keys[num_keys] = NULL;
|
||||
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);
|
||||
}
|
||||
/* 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);
|
||||
}
|
||||
} else if (strcmp(ZSTR_VAL(control_oid), LDAP_CONTROL_VLVREQUEST) == 0) {
|
||||
zval* tmp;
|
||||
@@ -575,15 +560,11 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
|
||||
vlvInfo.ldvlv_context = NULL;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
/* 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);
|
||||
}
|
||||
} else {
|
||||
php_error_docref(NULL, E_WARNING, "Control OID %s does not expect an array as value", ZSTR_VAL(control_oid));
|
||||
@@ -592,7 +573,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:
|
||||
@@ -614,9 +595,11 @@ failure:
|
||||
}
|
||||
efree(tmpstrings2);
|
||||
}
|
||||
if (control_value != NULL) {
|
||||
ber_memfree(control_value);
|
||||
control_value = NULL;
|
||||
if (control_value.bv_val != NULL && control_value_alloc != 0) {
|
||||
ber_memfree(control_value.bv_val);
|
||||
}
|
||||
if (ber != NULL) {
|
||||
ber_free(ber, 1);
|
||||
}
|
||||
if (ldap_attrs != NULL) {
|
||||
efree(ldap_attrs);
|
||||
@@ -1488,7 +1471,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;
|
||||
LDAPMessage *ldap_res = NULL;
|
||||
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;
|
||||
@@ -1688,6 +1671,11 @@ 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 {
|
||||
@@ -4016,7 +4004,7 @@ PHP_FUNCTION(ldap_control_paged_result)
|
||||
zval *link;
|
||||
char *cookie = NULL;
|
||||
size_t cookie_len = 0;
|
||||
struct berval lcookie = { 0, NULL };
|
||||
struct berval lcookie = { 0L, NULL };
|
||||
ldap_linkdata *ld;
|
||||
LDAP *ldap;
|
||||
BerElement *ber = NULL;
|
||||
@@ -4311,38 +4299,31 @@ PHP_FUNCTION(ldap_exop)
|
||||
PHP_FUNCTION(ldap_exop_passwd)
|
||||
{
|
||||
zval *link, *serverctrls;
|
||||
struct berval luser, loldpw, lnewpw, lgenpasswd;
|
||||
LDAPControl **lserverctrls = NULL, **requestctrls = NULL;
|
||||
LDAPControl *ctrl, **ctrlp;
|
||||
LDAPMessage* ldap_res;
|
||||
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;
|
||||
ldap_linkdata *ld;
|
||||
int rc, myargcount = ZEND_NUM_ARGS(), msgid, err;
|
||||
char* errmsg;
|
||||
|
||||
luser.bv_len = 0;
|
||||
loldpw.bv_len = 0;
|
||||
lnewpw.bv_len = 0;
|
||||
char* errmsg = NULL;
|
||||
|
||||
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) {
|
||||
RETURN_FALSE;
|
||||
RETVAL_FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
switch (myargcount) {
|
||||
case 5:
|
||||
requestctrls = safe_emalloc(2, sizeof(*requestctrls), 0);
|
||||
*requestctrls = NULL;
|
||||
ctrlp = requestctrls;
|
||||
|
||||
/* ldap_create_passwordpolicy_control() allocates ctrl */
|
||||
if (ldap_create_passwordpolicy_control(ld->link, &ctrl) == LDAP_SUCCESS) {
|
||||
*ctrlp = ctrl;
|
||||
++ctrlp;
|
||||
requestctrls[0] = ctrl;
|
||||
}
|
||||
|
||||
*ctrlp = NULL;
|
||||
}
|
||||
|
||||
/* asynchronous call to get result and controls */
|
||||
@@ -4352,35 +4333,44 @@ PHP_FUNCTION(ldap_exop_passwd)
|
||||
requestctrls,
|
||||
NULL, &msgid);
|
||||
|
||||
if (requestctrls != NULL) {
|
||||
efree(requestctrls);
|
||||
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);
|
||||
RETURN_FALSE;
|
||||
RETVAL_FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
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);
|
||||
RETURN_FALSE;
|
||||
RETVAL_FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
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);
|
||||
ldap_msgfree(ldap_res);
|
||||
RETURN_FALSE;
|
||||
RETVAL_FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rc = ldap_parse_result(ld->link, ldap_res, &err, NULL, &errmsg, NULL, (myargcount > 4 ? &lserverctrls : NULL), 1);
|
||||
rc = ldap_parse_result(ld->link, ldap_res, &err, NULL, &errmsg, NULL, (myargcount > 4 ? &lserverctrls : NULL), 0);
|
||||
if( rc != LDAP_SUCCESS ) {
|
||||
php_error_docref(NULL, E_WARNING, "Passwd modify extended operation failed: %s (%d)", ldap_err2string(rc), rc);
|
||||
RETURN_FALSE;
|
||||
RETVAL_FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -4394,12 +4384,16 @@ PHP_FUNCTION(ldap_exop_passwd)
|
||||
RETVAL_FALSE;
|
||||
}
|
||||
|
||||
if (myargcount > 4) {
|
||||
zval_ptr_dtor(serverctrls);
|
||||
_php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, 0);
|
||||
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);
|
||||
}
|
||||
|
||||
ldap_memfree(lgenpasswd.bv_val);
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
||||
@@ -223,6 +223,9 @@ 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);
|
||||
}
|
||||
|
||||
@@ -31,10 +31,11 @@
|
||||
|
||||
#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;
|
||||
|
||||
@@ -93,28 +94,6 @@ 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));
|
||||
@@ -143,39 +122,20 @@ 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;
|
||||
|
||||
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)) {
|
||||
mapping_base = MapViewOfFileEx(memfile, FILE_MAP_ALL_ACCESS, 0, 0, ACCEL_BASE_POINTER_SIZE, NULL);
|
||||
if (mapping_base == NULL) {
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
wanted_mapping_base = ((void**)mapping_base)[0];
|
||||
execute_ex_base = ((void**)mapping_base)[1];
|
||||
UnmapViewOfFile(mapping_base);
|
||||
|
||||
execute_ex_moved = (void *)execute_ex != execute_ex_base;
|
||||
|
||||
@@ -231,7 +191,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 *) mapping_base;
|
||||
smm_shared_globals = (zend_smm_shared_globals *) ((char*)mapping_base + ACCEL_BASE_POINTER_SIZE);
|
||||
|
||||
return SUCCESSFULLY_REATTACHED;
|
||||
}
|
||||
@@ -349,23 +309,12 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_
|
||||
*error_in = "MapViewOfFile";
|
||||
return ALLOC_FAILURE;
|
||||
} else {
|
||||
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);
|
||||
((void**)mapping_base)[0] = mapping_base;
|
||||
((void**)mapping_base)[1] = (void*)execute_ex;
|
||||
}
|
||||
|
||||
shared_segment->pos = 0;
|
||||
shared_segment->size = requested_size;
|
||||
shared_segment->pos = ACCEL_BASE_POINTER_SIZE;
|
||||
shared_segment->size = requested_size - ACCEL_BASE_POINTER_SIZE;
|
||||
|
||||
zend_shared_alloc_unlock_win32();
|
||||
|
||||
|
||||
@@ -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 = &info;
|
||||
vec[0].iov_base = (void *)&info;
|
||||
vec[0].iov_len = sizeof(info);
|
||||
vec[1].iov_base = buf;
|
||||
vec[1].iov_len = script->size;
|
||||
|
||||
@@ -36,6 +36,33 @@
|
||||
|
||||
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;
|
||||
|
||||
@@ -691,6 +691,7 @@ 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:
|
||||
|
||||
@@ -103,8 +103,7 @@ 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");
|
||||
zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode, "SQLSTATE[%s] [%d] %s",
|
||||
*pdo_err, einfo->errcode, einfo->errmsg);
|
||||
pdo_throw_exception(einfo->errcode, einfo->errmsg, pdo_err);
|
||||
}
|
||||
|
||||
PDO_DBG_RETURN(einfo->errcode);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
--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)
|
||||
@@ -101,8 +101,7 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
|
||||
}
|
||||
|
||||
if (!dbh->methods) {
|
||||
zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode, "SQLSTATE[%s] [%d] %s",
|
||||
*pdo_err, einfo->errcode, einfo->errmsg);
|
||||
pdo_throw_exception(einfo->errcode, einfo->errmsg, pdo_err);
|
||||
}
|
||||
|
||||
return errcode;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
--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)
|
||||
@@ -76,8 +76,7 @@ int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int li
|
||||
}
|
||||
|
||||
if (!dbh->methods) {
|
||||
zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode, "SQLSTATE[%s] [%d] %s",
|
||||
*pdo_err, einfo->errcode, einfo->errmsg);
|
||||
pdo_throw_exception(einfo->errcode, einfo->errmsg, pdo_err);
|
||||
}
|
||||
|
||||
return einfo->errcode;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
--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.
@@ -0,0 +1,14 @@
|
||||
--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
@@ -705,7 +705,7 @@ foundit:
|
||||
efree(actual_alias);
|
||||
}
|
||||
|
||||
zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), actual_alias, mydata->alias_len, mydata);
|
||||
zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), mydata->alias, mydata->alias_len, mydata);
|
||||
} else {
|
||||
phar_archive_data *fd_ptr;
|
||||
|
||||
|
||||
@@ -29,10 +29,12 @@ $_SESSION["Blah"] = "Hello World!";
|
||||
$_SESSION["Foo"] = FALSE;
|
||||
$_SESSION["Guff"] = 1234567890;
|
||||
var_dump($_SESSION);
|
||||
$oldsession = $_SESSION;
|
||||
|
||||
var_dump(session_write_close());
|
||||
session_start();
|
||||
var_dump($_SESSION);
|
||||
// the session may have been GC'd or not; we accept either outcome
|
||||
var_dump($_SESSION === $oldsession || $_SESSION === []);
|
||||
var_dump(session_destroy());
|
||||
session_start();
|
||||
var_dump($_SESSION);
|
||||
@@ -51,14 +53,7 @@ array(3) {
|
||||
int(1234567890)
|
||||
}
|
||||
bool(true)
|
||||
array(3) {
|
||||
["Blah"]=>
|
||||
string(12) "Hello World!"
|
||||
["Foo"]=>
|
||||
bool(false)
|
||||
["Guff"]=>
|
||||
int(1234567890)
|
||||
}
|
||||
bool(true)
|
||||
bool(true)
|
||||
array(0) {
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1);
|
||||
sapi_add_header("HTTP/1.1 500 Internal Server Error", sizeof("HTTP/1.1 500 Internal Server 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);
|
||||
|
||||
@@ -197,14 +197,13 @@ PHP_FUNCTION(socket_sendmsg)
|
||||
res = sendmsg(php_sock->bsd_socket, msghdr, (int)flags);
|
||||
|
||||
if (res != -1) {
|
||||
zend_llist_destroy(allocations);
|
||||
efree(allocations);
|
||||
|
||||
RETURN_LONG((zend_long)res);
|
||||
RETVAL_LONG((zend_long)res);
|
||||
} else {
|
||||
PHP_SOCKET_ERROR(php_sock, "error in sendmsg", errno);
|
||||
RETURN_FALSE;
|
||||
RETVAL_FALSE;
|
||||
}
|
||||
|
||||
allocations_dispose(&allocations);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(socket_recvmsg)
|
||||
@@ -254,7 +253,6 @@ 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) {
|
||||
@@ -265,14 +263,15 @@ 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));
|
||||
RETURN_FALSE;
|
||||
RETVAL_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG((zend_long)res);
|
||||
allocations_dispose(&allocations);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(socket_cmsg_space)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--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
|
||||
@@ -2885,6 +2885,7 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -3615,7 +3615,7 @@ PHPAPI int php_array_merge_recursive(HashTable *dest, HashTable *src) /* {{{ */
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
Z_TRY_ADDREF_P(src_entry);
|
||||
Z_TRY_ADDREF_P(src_zval);
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(dest_zval), src_zval);
|
||||
}
|
||||
zval_ptr_dtor(&tmp);
|
||||
|
||||
+1
-1
@@ -1114,7 +1114,7 @@ PHP_FUNCTION(dns_get_mx)
|
||||
}
|
||||
}
|
||||
php_dns_free_handle(handle);
|
||||
RETURN_TRUE;
|
||||
RETURN_BOOL(zend_hash_num_elements(Z_ARRVAL_P(mx_list)) != 0);
|
||||
}
|
||||
/* }}} */
|
||||
#endif /* HAVE_FULL_DNS_FUNCS */
|
||||
|
||||
@@ -1496,6 +1496,11 @@ 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);
|
||||
|
||||
+6
-10
@@ -4269,12 +4269,9 @@ 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,
|
||||
*replace_entry = NULL;
|
||||
zval *search_entry;
|
||||
zend_string *tmp_result,
|
||||
*tmp_subject_str,
|
||||
*tmp_replace_entry_str = NULL,
|
||||
*replace_entry_str;
|
||||
*tmp_subject_str;
|
||||
char *replace_value = NULL;
|
||||
size_t replace_len = 0;
|
||||
zend_long replace_count = 0;
|
||||
@@ -4308,10 +4305,12 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
|
||||
/* 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) {
|
||||
@@ -4368,15 +4367,12 @@ 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);
|
||||
|
||||
if (tmp_replace_entry_str) {
|
||||
zend_string_release_ex(tmp_replace_entry_str, 0);
|
||||
tmp_replace_entry_str = NULL;
|
||||
}
|
||||
zend_tmp_string_release(tmp_replace_entry_str);
|
||||
|
||||
if (subject_str == tmp_result) {
|
||||
zend_string_delref(subject_str);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
--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"
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,5 @@
|
||||
--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__);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
--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
|
||||
@@ -0,0 +1,16 @@
|
||||
--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
|
||||
@@ -10,15 +10,19 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$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";
|
||||
}
|
||||
$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";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Hosts: 1, weights: 1
|
||||
Hosts: 2, weights: 2
|
||||
Result: true, hosts: 1, weights: 1
|
||||
Result: true, hosts: 2, weights: 2
|
||||
Result: false, hosts: 0, weights: 0
|
||||
@@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Bug #79951: Memory leak in str_replace of empty string
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(str_replace([""], [1000], "foo"));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(3) "foo"
|
||||
@@ -0,0 +1,17 @@
|
||||
--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
@@ -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(&parser->index, return_value);
|
||||
ZVAL_COPY_VALUE(&parser->index, return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1559,7 +1559,7 @@ PHP_FUNCTION(xml_parser_free)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (zend_list_delete(Z_RES(parser->index)) == FAILURE) {
|
||||
if (zend_list_close(Z_RES(parser->index)) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -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 21
|
||||
#define PHP_EXTRA_VERSION "-dev"
|
||||
#define PHP_VERSION "7.3.21-dev"
|
||||
#define PHP_VERSION_ID 70321
|
||||
#define PHP_RELEASE_VERSION 22
|
||||
#define PHP_EXTRA_VERSION ""
|
||||
#define PHP_VERSION "7.3.22"
|
||||
#define PHP_VERSION_ID 70322
|
||||
@@ -744,6 +744,10 @@ 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
|
||||
|
||||
@@ -365,7 +365,13 @@ 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) /* {{{ */
|
||||
{
|
||||
return (const char*)zend_hash_str_find_ptr(&server->extension_mime_types, ext, 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;
|
||||
} /* }}} */
|
||||
|
||||
PHP_FUNCTION(apache_request_headers) /* {{{ */
|
||||
@@ -2140,9 +2146,12 @@ 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 || memcmp(client->request.ext, "php", 3) || !client->request.path_translated) {
|
||||
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) {
|
||||
is_static_file = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
#include "lscriu.c"
|
||||
#endif
|
||||
|
||||
#define SAPI_LSAPI_MAX_HEADER_LENGTH 2048
|
||||
#define SAPI_LSAPI_MAX_HEADER_LENGTH LSAPI_RESP_HTTP_HEADER_MAX
|
||||
|
||||
/* 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.6",
|
||||
"LiteSpeed V7.7",
|
||||
|
||||
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 )) {
|
||||
if (p && len > 0 && len < LSAPI_RESP_HTTP_HEADER_MAX) {
|
||||
memmove( headerBuf, h->header, len );
|
||||
while( len > 0 && (isspace( headerBuf[len-1])) ) {
|
||||
--len;
|
||||
|
||||
+225
-11
@@ -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 )
|
||||
{
|
||||
setreuid( s_uid, uid );
|
||||
if (setreuid( s_uid, uid )) {};
|
||||
if ( !(*fp_lve_is_available)() )
|
||||
s_enable_lve = 0;
|
||||
setreuid( uid, s_uid );
|
||||
if (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
|
||||
write( STDERR_FILENO, achError, n );
|
||||
if (write( STDERR_FILENO, achError, n )) {};
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2622,7 +2622,8 @@ int LSAPI_ParseSockAddr( const char * pBind, struct sockaddr * pAddr )
|
||||
while( isspace( *pBind ) )
|
||||
++pBind;
|
||||
|
||||
strncpy( achAddr, pBind, 256 );
|
||||
strncpy(achAddr, pBind, 255);
|
||||
achAddr[255] = 0;
|
||||
|
||||
switch( *p )
|
||||
{
|
||||
@@ -2775,6 +2776,9 @@ 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;
|
||||
}
|
||||
|
||||
@@ -2830,6 +2834,11 @@ 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;
|
||||
@@ -2928,7 +2937,10 @@ static void lsapi_sigchild( int signal )
|
||||
static int lsapi_init_children_status(void)
|
||||
{
|
||||
int size = 4096;
|
||||
int max_children = g_prefork_server->m_iMaxChildren
|
||||
int max_children;
|
||||
if (g_prefork_server->m_pChildrenStatus)
|
||||
return 0;
|
||||
max_children = g_prefork_server->m_iMaxChildren
|
||||
+ g_prefork_server->m_iExtraChildren;
|
||||
|
||||
char * pBuf;
|
||||
@@ -2949,6 +2961,8 @@ 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;
|
||||
}
|
||||
|
||||
@@ -3118,8 +3132,6 @@ 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));
|
||||
@@ -3141,7 +3153,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) {
|
||||
@@ -3219,8 +3231,6 @@ 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 );
|
||||
@@ -3312,6 +3322,210 @@ 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,
|
||||
|
||||
@@ -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,6 +91,7 @@ typedef struct lsapi_request
|
||||
char * m_pRespHeaderBuf;
|
||||
char * m_pRespHeaderBufEnd;
|
||||
char * m_pRespHeaderBufPos;
|
||||
struct lsapi_child_status * child_status;
|
||||
|
||||
|
||||
struct iovec * m_pIovec;
|
||||
@@ -395,6 +396,12 @@ 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,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
if [[ "$ENABLE_MAINTAINER_ZTS" == 1 ]]; then
|
||||
TS="--enable-maintainer-zts";
|
||||
else
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define NTDDI_VERSION 0x06010000
|
||||
|
||||
/* Default PHP / PEAR directories */
|
||||
#define PHP_CONFIG_FILE_PATH (getenv("SystemRoot")?getenv("SystemRoot"):"")
|
||||
#define PHP_CONFIG_FILE_PATH ""
|
||||
#define CONFIGURATION_FILE_PATH "php.ini"
|
||||
#define PEAR_INSTALLDIR "@PREFIX@\\pear"
|
||||
#define PHP_BINDIR "@PREFIX@"
|
||||
|
||||
Reference in new issue
Block a user