Compare commits

...
76 Commits
Author SHA1 Message Date
Ferenc Kovacs 404e846542 5.6.35 2018-03-28 23:28:58 +02:00
Ferenc Kovacs cb981e39c2 [ci skip] 5.6.36 will be next 2018-03-28 23:14:30 +02:00
Anatol Belski 2885f62816 [ci skip] Update NEWS 2018-03-27 14:24:43 +02:00
Jakub Zelenka d20bebfe13 Do not set PR_SET_DUMPABLE by default 2018-03-27 14:18:01 +02:00
Ferenc Kovacs 3db7427b71 5.6.35 is next 2018-02-27 23:57:06 +01:00
Anatol Belski 4698a412bf [ci skip] Update NEWS 2018-02-27 11:31:37 +01:00
Stanislav Malyshev 523f230c83 Fix bug #75981: prevent reading beyond buffer start 2018-02-26 22:25:51 -08:00
Stanislav Malyshev 1f4b057b63 [ci skip] Set FPM maintainership
As per http://news.php.net/php.internals/101897, Jakub is officially
annointed as new FPM maintainer.
2018-02-23 16:43:10 -08:00
Remi Collet 67ec3ce1ec 2018 2018-01-03 15:12:39 +01:00
Ferenc Kovacs 028507f1f6 php 5.6.34 is next 2018-01-03 00:30:58 +01:00
Stanislav Malyshev 2881199c80 Update NEWS 2018-01-01 19:53:00 -08:00
Christoph M. Becker 8d6e958867 Fixed bug #75571: Potential infinite loop in gdImageCreateFromGifCtx
Due to a signedness confusion in `GetCode_` a corrupt GIF file can
trigger an infinite loop.  Furthermore we make sure that a GIF without
any palette entries is treated as invalid *after* open palette entries
have been removed.
2018-01-01 19:51:26 -08:00
Stanislav Malyshev 73ca9b3773 Fix bug #74782: remove file name from output to avoid XSS 2018-01-01 19:51:02 -08:00
Anatol Belski f6e8ce8121 Backport and apply upstream patch for CVE-2017-14107 2017-10-27 13:16:56 +02:00
Ferenc Kovacs f600785f65 5.6.33 is next 2017-10-25 03:36:30 +02:00
Rasmus Lerdorf ad7ed6fe21 These tests all assume that IPV6 is available. 2017-10-25 02:21:16 +02:00
Ferenc Kovacs 787e3a1ee4 fix the travis build for PHP-5.6 using precise instead of trusty 2017-10-25 01:51:48 +02:00
Ferenc Kovacs 9839d3a953 fix the travis build for PHP-5.6 using precise instead of trusty 2017-10-25 01:47:50 +02:00
Anatol Belski 45ac5edbd9 Parametrize the expected value to avoid platform false positives 2017-10-24 18:33:21 +02:00
Anatol Belski 7d06a5c89f [ci skip] update NEWS 2017-10-24 14:16:54 +02:00
Anatol Belski 37acebcc8c Fixed bug #72535 arcfour encryption stream filter crashes php 2017-10-24 13:59:18 +02:00
Anatol Belski a7815e63bd Fixed bug #75055 Out-Of-Bounds Read in timelib_meridian() 2017-10-24 11:28:17 +02:00
Anatol Belski d37658be6c Apply upstream patch for CVE-2016-1283
Fix bug #75207, see also
https://bugzilla.redhat.com/show_bug.cgi?id=1295385
https://vcs.pcre.org/pcre?view=revision&revision=1636

(cherry picked from commit d11fceab15)
2017-10-24 11:10:11 +02:00
Ferenc Kovacs 390f64701d add missing NEWS entry for #74087 and also fix the formatting 2017-07-06 00:10:07 +02:00
Ferenc Kovacs 7991a88675 move NEWS entry to the correct place, also bump the version 2017-07-06 00:05:14 +02:00
Remi Collet 55b880070c NEWS for oniguruma 2017-07-05 09:26:55 +02:00
Remi Collet 703be4f77e Patch from the upstream git
https://github.com/kkos/oniguruma/issues/60 (CVE-2017-9228)

Thanks to Mamoru TASAKA <mtasaka@fedoraproject.org>
2017-07-05 09:26:06 +02:00
Remi Collet 27a743b82b Patch from the upstream git
https://github.com/kkos/oniguruma/issues/59 (CVE-2017-9229)
b690371bbf97794b4a1d3f295d4fb9a8b05d402d Modified for onig 5.9.6

Thanks to Mamoru TASAKA <mtasaka@fedoraproject.org>
2017-07-05 09:25:57 +02:00
Remi Collet bdf7393ddb Patch from the upstream git
https://github.com/kkos/oniguruma/issues/58 (CVE-2017-9227)

Thanks to Mamoru TASAKA <mtasaka@fedoraproject.org>
2017-07-05 09:25:49 +02:00
Remi Collet 2693e52113 Patch from the upstream git
https://github.com/kkos/oniguruma/issues/57 (CVE-2017-9224)

Thanks to Mamoru TASAKA <mtasaka@fedoraproject.org>
2017-07-05 09:25:39 +02:00
Remi Collet 4e68b2c52b Patch from the upstream git
https://github.com/kkos/oniguruma/issues/55 (CVE-2017-9226)
b4bf968ad52afe14e60a2dc8a95d3555c543353a Modified for onig 5.9.6
f015fbdd95f76438cd86366467bb2b39870dd7c6 Modified for onig 5.9.6

Thanks to Mamoru TASAKA <mtasaka@fedoraproject.org>
2017-07-05 09:25:27 +02:00
Stanislav Malyshev f269cdcd4f Improve fix for #74145 2017-07-04 21:10:08 -07:00
Stanislav Malyshev e46d589624 Fix tests 2017-07-04 20:12:57 -07:00
Stanislav Malyshev 12107d619b Update NEWS 2017-07-04 19:30:29 -07:00
Stanislav Malyshev f7f4fd4706 Fix bug #74087
Ported from https://vcs.pcre.org/pcre/code/trunk/pcre_jit_compile.c?r1=1676&r2=1680&view=patch
2017-07-04 19:21:28 -07:00
Derick Rethans e8b7698f5e Fixed parsing of strange formats with mixed month/day and time strings 2017-07-04 19:19:30 -07:00
Stanislav Malyshev 2aae60461c Fix bug #74145 - wddx parsing empty boolean tag leads to SIGSEGV 2017-07-04 19:06:42 -07:00
Nikita Popov f8c514ba6b Fixed bug #74111 2017-07-04 19:06:16 -07:00
Christoph M. Becker 8dc4f4dc9e Fix #74435: Buffer over-read into uninitialized memory
The stack allocated color map buffers were not zeroed before usage, and
so undefined palette indexes could cause information leakage.
2017-07-04 19:00:57 -07:00
Stanislav Malyshev 5f8380d33e Fix bug #74603 - use correct buffer size 2017-07-04 19:00:03 -07:00
Stanislav Malyshev 89637c6b41 Fix bug #74651 - check EVP_SealInit as it can return -1 2017-07-04 12:32:06 -07:00
Stanislav Malyshev 3eecee16d1 Update NEWS 2017-06-24 23:32:59 -07:00
Nikita Popov 0f8cf3b849 Fix bug #73807 2017-06-20 00:23:44 -07:00
Remi Collet 0e21d8066b fix test for 32bits (int -> float)
(cherry picked from commit 0f1ae93bfa)
2017-02-01 11:49:52 +01:00
Ferenc Kovacs cf649f59cb update NEWS 2017-01-19 01:16:31 +01:00
Christoph M. Becker d2274b01cb Fix #73869: Signed Integer Overflow gd_io.c
GD2 stores the number of horizontal and vertical chunks as words (i.e. 2
byte unsigned). These values are multiplied and assigned to an int when
reading the image, what can cause integer overflows. We have to avoid
that, and also make sure that either chunk count is actually greater
than zero. If illegal chunk counts are detected, we bail out from
reading the image.

(cherry picked from commit 5b5d9db3988b829e0b121b74bb3947f01c2796a1)
2017-01-17 09:30:58 +01:00
Christoph M. Becker f1b2afc9d9 Fix #73868: DOS vulnerability in gdImageCreateFromGd2Ctx()
We must not pretend that there are image data if there are none. Instead
we fail reading the image file gracefully.

(cherry picked from commit cdb648dc4115ce0722f3cc75e6a65115fc0e56ab)
2017-01-17 09:30:43 +01:00
Nikita Popov 6477bb724e Add additional serialize tests for fixed bugs
These have been fixed as a side-effect of the delayed __wakeup
patch.
2017-01-16 13:24:13 +01:00
Stanislav Malyshev 50b38322b9 Fix typo 2017-01-16 00:23:06 -08:00
Stanislav Malyshev 814966ad33 Fix test 2017-01-15 18:42:22 -08:00
Stanislav Malyshev 0ab1af7d3e Update more functions with path check 2017-01-15 17:31:08 -08:00
Mitch Hagstrand ad9c552b12 Fix glob-wrapper.phpt to not fail in Windows 2017-01-10 23:18:52 +01:00
Sara Golemon 7e49e8e797 Fix open_basedir check for glob:// opendir wrapper
php_check_open_basedir() expects a local filesystem path,
but we're handing it a `glob://...` URI instead.

Move the check to after the path trim so that we're checking
a meaningful pathspec.
2017-01-09 11:02:50 -08:00
Remi Collet db890956ec add skip when json not loaded 2017-01-06 06:23:59 +01:00
Ferenc Kovacs 3b14d7b84b 5.6.31 is next 2017-01-06 01:43:11 +01:00
Nikita Popov 900b17b15f Fix printf modifier 2017-01-05 11:37:06 +01:00
Nikita Popov f697874e3f Add tests for delayed __wakeup() 2017-01-05 00:21:48 +01:00
Nikita Popov 0426b916df Implement delayed __wakeup 2017-01-05 00:21:48 +01:00
Stanislav Malyshev fa2125df67 Merge branch 'PHP-5.6.30' into PHP-5.6
* PHP-5.6.30:
  Fix bug #73737 FPE when parsing a tag format
  Fix bug #73773 - Seg fault when loading hostile phar
  Fix bug #73825 - Heap out of bounds read on unserialize in finish_nested_data()
  Fix bug #73768 - Memory corruption when loading hostile phar
  Fix int overflows in phar (bug #73764)
2017-01-02 20:56:32 -08:00
Nikita Popov a65ad951ad FIx bug #70213 2017-01-01 14:10:49 +01:00
Stanislav Malyshev 1cda0d7c2f Fix bug #73737 FPE when parsing a tag format 2016-12-31 19:31:49 -08:00
Stanislav Malyshev e5246580a8 Fix bug #73773 - Seg fault when loading hostile phar 2016-12-31 18:47:50 -08:00
Stanislav Malyshev 16b3003ffc Fix bug #73825 - Heap out of bounds read on unserialize in finish_nested_data() 2016-12-30 16:59:46 -08:00
Stanislav Malyshev b28b8b2fee Fix bug #73768 - Memory corruption when loading hostile phar 2016-12-30 15:57:24 -08:00
Stanislav Malyshev ca46d0acbc Fix int overflows in phar (bug #73764) 2016-12-30 15:39:48 -08:00
Christoph M. Becker 2ba3b27594 Revert "Fix #73530: Unsetting result set may reset other result set"
This reverts commit eb570294a2.

That commit caused a regression, so it's probably best to revert it, and
to tackle the issue for the next minor release.
2016-12-29 12:59:04 +01:00
Anatol Belski 79e47aae41 fix C89 compat 2016-12-17 20:43:32 +01:00
Matteo Beccati 0c9324ea9b Skip tests when secure_file_priv dir not writable 2016-12-15 09:31:00 +01:00
Ferenc Kovacs 60da307c61 update NEWS 2016-12-08 07:05:32 +01:00
Anatol Belski c89306ac52 fix leak, take 2 2016-12-06 16:12:39 +01:00
Anatol Belski b04d60626d fix leak, take on 5.6 2016-12-06 14:34:27 +01:00
Stanislav Malyshev d7ce944cf1 This still leaks memory, I don't have enough knowledge in WDDX code to fix them :( 2016-12-05 22:32:59 -08:00
Stanislav Malyshev 266ecb6d0a Fix bug #73631 - Invalid read when wddx decodes empty boolean element 2016-12-05 21:40:55 -08:00
Adrien Crivelli cf2496140d Fix minor typo 2016-12-03 14:15:52 +01:00
Dmitry Stogov 1cd566e13f Workaround for GCC-4.9.2 bug 2016-12-01 15:46:52 +03:00
Stanislav Malyshev c8778eb293 oops, changed in wrong place 2016-11-27 16:11:41 -08:00
105 changed files with 8569 additions and 6841 deletions

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
dist: precise
language: c
sudo: false
addons:
+1 -1
View File
@@ -74,7 +74,7 @@ MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: fpm
PRIMARY MAINTAINER: Antony Dovgal <tony2001@php.net>, Jerome Loyet <fat@php.net>
PRIMARY MAINTAINER: Jakub Zelenka <bukka@php.net>
MAINTENANCE: Maintained
STATUS: Working
SINCE: 5.3.3
+85 -1
View File
@@ -1,14 +1,94 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ?? 2017, PHP 5.6.30
29 Mar 2018, PHP 5.6.35
- FPM:
. Fixed bug #75605 (Dumpable FPM child processes allow bypassing opcache
access controls). (Jakub Zelenka)
01 Mar 2018, PHP 5.6.34
- Standard:
. Fixed bug #75981 (stack-buffer-overflow while parsing HTTP response). (Stas)
04 Jan 2018, PHP 5.6.33
- GD:
. Fixed bug #75571 (Potential infinite loop in gdImageCreateFromGifCtx). (cmb)
- Phar:
. Fixed bug #74782 (Reflected XSS in .phar 404 page). (Stas)
26 Sep 2017, PHP 5.6.32
- Date:
. Fixed bug #75055 (Out-Of-Bounds Read in timelib_meridian()). (Derick)
- mcrypt:
. Fixed bug #72535 (arcfour encryption stream filter crashes php). (Leigh)
- PCRE:
. Fixed bug #75207 (applied upstream patch for CVE-2016-1283). (Anatol)
06 Jul 2017, PHP 5.6.31
- Core:
. Fixed bug #73807 (Performance problem with processing post request over
2000000 chars). (Nikita)
. Fixed bug #74111 (Heap buffer overread (READ: 1) finish_nested_data from
unserialize). (Nikita)
. Fixed bug #74603 (PHP INI Parsing Stack Buffer Overflow Vulnerability).
(Stas)
. Fixed bug #74819 (wddx_deserialize() heap out-of-bound read via
php_parse_date()). (Derick)
- GD:
. Fixed bug #74435 (Buffer over-read into uninitialized memory). (cmb)
- mbstring:
. Add oniguruma upstream fix (CVE-2017-9224, CVE-2017-9226, CVE-2017-9227,
CVE-2017-9228, CVE-2017-9229) (Remi, Mamoru TASAKA)
- OpenSSL:
. Fixed bug #74651 (negative-size-param (-1) in memcpy in zif_openssl_seal()).
(Stas)
- PCRE:
. Fixed bug #74087 (Segmentation fault in PHP7.1.1(compiled using the bundled PCRE library)).
(Stas)
- WDDX:
. Fixed bug #74145 (wddx parsing empty boolean tag leads to SIGSEGV). (Stas)
19 Jan 2017, PHP 5.6.30
- EXIF:
. Fixed bug #73737 (FPE when parsing a tag format). (Stas)
- GD:
. Fixed bug #73549 (Use after free when stream is passed to imagepng). (cmb)
. Fixed bug #73868 (DOS vulnerability in gdImageCreateFromGd2Ctx()). (cmb)
. Fixed bug #73869 (Signed Integer Overflow gd_io.c). (cmb)
- Intl:
. Fixed bug #68447 (grapheme_extract take an extra trailing character).
(SATŌ Kentarō)
- Phar:
. Fixed bug #73764 (Crash while loading hostile phar archive). (Stas)
. Fixed bug #73768 (Memory corruption when loading hostile phar). (Stas)
. Fixed bug #73773 (Seg fault when loading hostile phar). (Stas)
- SQLite3:
. Reverted fix for bug #73530 (Unsetting result set may reset other result
set). (cmb)
- Standard:
. Fixed bug #70213 (Unserialize context shared on double class lookup).
(Taoguang Chen)
. Fixed bug #73825 (Heap out of bounds read on unserialize in
finish_nested_data()). (Stas)
08 Dec 2016, PHP 5.6.29
- Mbstring:
@@ -40,6 +120,10 @@ PHP NEWS
. Fixed bug #73297 (HTTP stream wrapper should ignore HTTP 100 Continue).
(rowan dot collins at gmail dot com)
- WDDX:
. Fixed bug #73631 (Memory leak due to invalid wddx stack processing).
(bughunter at fosec dot vn).
10 Nov 2016, PHP 5.6.28
- Core:
+1
View File
@@ -0,0 +1 @@
0=0&~2000000000
+15
View File
@@ -0,0 +1,15 @@
--TEST--
Bug #74603 (PHP INI Parsing Stack Buffer Overflow Vulnerability)
--SKIPIF--
<?php
if (PHP_INT_MAX !== 2147483647)
die('skip for 32-bit only');
--FILE--
<?php
var_dump(parse_ini_file(__DIR__ . "/bug74603.ini", true, INI_SCANNER_NORMAL));
?>
--EXPECT--
array(1) {
[0]=>
string(1) "0"
}
+1 -1
View File
@@ -53,7 +53,7 @@ static void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2)
{
int i_result;
int i_op1, i_op2;
char str_result[MAX_LENGTH_OF_LONG];
char str_result[MAX_LENGTH_OF_LONG+1];
i_op1 = atoi(Z_STRVAL_P(op1));
free(Z_STRVAL_P(op1));
+4
View File
@@ -1184,6 +1184,10 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, const c
ALLOCA_FLAG(use_heap)
if (EXPECTED(key != NULL)) {
#if (ZEND_GCC_VERSION == 4009) && !(defined(ZTS) && defined(NETWARE)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
/* This is a workaround for bug in GCC 4.9.2 */
use_heap = 0;
#endif
lc_function_name = Z_STRVAL(key->constant);
hash_value = key->hash_value;
} else {
+2 -2
View File
@@ -119,8 +119,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=5
PHP_MINOR_VERSION=6
PHP_RELEASE_VERSION=30
PHP_EXTRA_VERSION="-dev"
PHP_RELEASE_VERSION=35
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`
+1 -1
View File
@@ -35,7 +35,7 @@ static void curlfile_ctor(INTERNAL_FUNCTION_PARAMETERS)
int fname_len, mime_len, postname_len;
zval *cf = return_value;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ss", &fname, &fname_len, &mime, &mime_len, &postname, &postname_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|ss", &fname, &fname_len, &mime, &mime_len, &postname, &postname_len) == FAILURE) {
return;
}
+7261 -6578
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -899,7 +899,7 @@ datefull = day ([ \t.-])* monthtext ([ \t.-])* year;
datenoday = monthtext ([ .\t-])* year4;
datenodayrev = year4 ([ .\t-])* monthtext;
datetextual = monthtext ([ .\t-])* day [,.stndrh\t ]+ year;
datenoyear = monthtext ([ .\t-])* day [,.stndrh\t ]*;
datenoyear = monthtext ([ .\t-])* day ([,.stndrh\t ]+|[\000]);
datenoyearrev = day ([ .\t-])* monthtext;
datenocolon = year4 monthlz daylz;
@@ -917,8 +917,8 @@ isoweek = year4 "-"? "W" weekofyear;
exif = year4 ":" monthlz ":" daylz " " hour24lz ":" minutelz ":" secondlz;
firstdayof = 'first day of';
lastdayof = 'last day of';
backof = 'back of ' hour24 space? meridian?;
frontof = 'front of ' hour24 space? meridian?;
backof = 'back of ' hour24 (space? meridian)?;
frontof = 'front of ' hour24 (space? meridian)?;
/* Common Log Format: 10/Oct/2000:13:55:36 -0700 */
clf = day "/" monthabbr "/" year4 ":" hour24lz ":" minutelz ":" secondlz space tzcorrection;
+1 -1
View File
@@ -40,7 +40,7 @@ object(DateInterval)#%d (15) {
["special_amount"]=>
int(-1)
["have_weekday_relative"]=>
int(9)
int(%d)
["have_special_relative"]=>
int(0)
}
+2 -2
View File
@@ -34,14 +34,14 @@ foreach ( $tests as $start => $data )
echo "\n";
?>
--EXPECT--
Sat, 23 Oct 2010 00:00:00 +0000
Fri, 15 Oct 2010 23:00:00 +0000
Wed, 15 Dec 2010 16:15:00 +0000
Mon, 20 Dec 2010 00:00:00 +0000
Mon, 20 Dec 2010 10:00:00 +0000
Tue, 21 Dec 2010 12:00:00 +0000
Mon, 03 Jan 2011 00:00:00 +0000
Mon, 03 Jan 2011 09:00:00 +0000
Sat, 23 Oct 2010 00:00:00 +0100
Fri, 15 Oct 2010 23:00:00 +0100
Sun, 28 Mar 2010 00:15:00 +0000
Sun, 28 Mar 2010 02:15:00 +0100
Sun, 28 Mar 2010 02:15:00 +0100
+3 -3
View File
@@ -1303,7 +1303,7 @@ static size_t exif_convert_any_to_int(void *value, int format, int motorola_inte
if (s_den == 0) {
return 0;
} else {
return php_ifd_get32s(value, motorola_intel) / s_den;
return (size_t)((double)php_ifd_get32s(value, motorola_intel) / s_den);
}
case TAG_FMT_SSHORT: return php_ifd_get16u(value, motorola_intel);
@@ -2855,7 +2855,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
}
if (components < 0) {
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=%s): Illegal components(%ld)", tag, exif_get_tagname(tag, tagname, -12, tag_table TSRMLS_CC), components);
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=%s): Illegal components(%d)", tag, exif_get_tagname(tag, tagname, -12, tag_table TSRMLS_CC), components);
return FALSE;
}
@@ -4210,7 +4210,7 @@ PHP_FUNCTION(exif_imagetype)
php_stream * stream;
int itype = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &imagefile, &imagefile_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &imagefile, &imagefile_len) == FAILURE) {
return;
}
+12
View File
@@ -0,0 +1,12 @@
--TEST--
Bug #73737 (Crash when parsing a tag format)
--SKIPIF--
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
--FILE--
<?php
$exif = exif_thumbnail(__DIR__ . '/bug73737.tiff');
var_dump($exif);
?>
--EXPECTF--
Warning: exif_thumbnail(bug73737.tiff): Error in TIFF: filesize(x0030) less than start of IFD dir(x10102) in %s line %d
bool(false)
Binary file not shown.
@@ -142,23 +142,23 @@ Warning: exif_imagetype(0.5): failed to open stream: No such file or directory i
bool(false)
-- Iteration 10 --
Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 11 --
Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 12 --
Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 13 --
Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 14 --
Warning: exif_imagetype() expects parameter 1 to be string, array given in %s on line %d
Warning: exif_imagetype() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 15 --
@@ -198,7 +198,7 @@ Warning: exif_imagetype(obj'ct): failed to open stream: No such file or director
bool(false)
-- Iteration 24 --
Warning: exif_imagetype() expects parameter 1 to be string, resource given in %s on line %d
Warning: exif_imagetype() expects parameter 1 to be a valid path, resource given in %s on line %d
NULL
-- Iteration 25 --
+10 -2
View File
@@ -136,6 +136,10 @@ static int _gd2GetHeader(gdIOCtxPtr in, int *sx, int *sy, int *cs, int *vers, in
GD2_DBG(php_gd_error("%d Chunks vertically", *ncy));
if (gd2_compressed(*fmt)) {
if (*ncx <= 0 || *ncy <= 0 || *ncx > INT_MAX / *ncy) {
GD2_DBG(printf ("Illegal chunk counts: %d * %d\n", *ncx, *ncy));
goto fail1;
}
nc = (*ncx) * (*ncy);
GD2_DBG(php_gd_error("Reading %d chunk index entries", nc));
if (overflow2(sizeof(t_chunk_info), nc)) {
@@ -340,12 +344,16 @@ gdImagePtr gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
for (x = xlo; x < xhi; x++) {
if (im->trueColor) {
if (!gdGetInt(&im->tpixels[y][x], in)) {
im->tpixels[y][x] = 0;
php_gd_error("gd2: EOF while reading\n");
gdImageDestroy(im);
return NULL;
}
} else {
int ch;
if (!gdGetByte(&ch, in)) {
ch = 0;
php_gd_error("gd2: EOF while reading\n");
gdImageDestroy(im);
return NULL;
}
im->pixels[y][x] = ch;
}
+8 -5
View File
@@ -147,6 +147,9 @@ gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */
int haveGlobalColormap;
gdImagePtr im = 0;
memset(ColorMap, 0, 3 * MAXCOLORMAPSIZE);
memset(localColorMap, 0, 3 * MAXCOLORMAPSIZE);
/*1.4//imageNumber = 1; */
if (! ReadOK(fd,buf,6)) {
return 0;
@@ -258,10 +261,6 @@ terminated:
if (!im) {
return 0;
}
if (!im->colorsTotal) {
gdImageDestroy(im);
return 0;
}
/* Check for open colors at the end, so
we can reduce colorsTotal and ultimately
BitsPerPixel */
@@ -272,6 +271,10 @@ terminated:
break;
}
}
if (!im->colorsTotal) {
gdImageDestroy(im);
return 0;
}
return im;
}
/* }}} */
@@ -372,7 +375,7 @@ static int
GetCode_(gdIOCtx *fd, CODE_STATIC_DATA *scd, int code_size, int flag, int *ZeroDataBlockP)
{
int i, j, ret;
unsigned char count;
int count;
if (flag) {
scd->curbit = 0;
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
--TEST--
Bug 73868 (DOS vulnerability in gdImageCreateFromGd2Ctx())
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
?>
--FILE--
<?php
var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73868.gd2'));
?>
===DONE===
--EXPECTF--
Warning: imagecreatefromgd2(): gd2: EOF while reading
in %s on line %d
Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d
bool(false)
===DONE===
+19
View File
@@ -0,0 +1,19 @@
--TEST--
Bug #73869 (Signed Integer Overflow gd_io.c)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
?>
--FILE--
<?php
var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869a.gd2'));
var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869b.gd2'));
?>
===DONE===
--EXPECTF--
Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d
bool(false)
Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d
bool(false)
===DONE===
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+27
View File
@@ -0,0 +1,27 @@
--TEST--
Bug #74435 (Buffer over-read into uninitialized memory)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
?>
--FILE--
<?php
$im = imagecreatefromgif(__DIR__ . DIRECTORY_SEPARATOR . 'bug74435.gif');
var_dump($im);
$width = imagesx($im);
$height = imagesy($im);
for ($i = 0; $i < $width; $i += 16) {
for ($j = 0; $j < $height; $j += 16) {
if (($index = imagecolorat($im, $i, $j)) >= 2) {
list($red, $green, $blue, $alpha) = array_values(imagecolorsforindex($im, $index));
if ($red !== 0 || $green !== 0 || $blue !== 0 || $alpha !== 0) {
echo "unexpected color at ($i, $j)\n";
}
}
}
}
?>
===DONE===
--EXPECTF--
resource(%d) of type (gd)
===DONE===
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

+15
View File
@@ -0,0 +1,15 @@
--TEST--
Bug #75571 (Infinite loop in GIF reading causing DoS)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
?>
--FILE--
<?php
var_dump(imagecreatefromgif(__DIR__ . '/bug75571.gif'));
?>
===DONE===
--EXPECTF--
Warning: imagecreatefromgif(): '%s' is not a valid GIF file in %s on line %d
bool(false)
===DONE===
+1 -1
View File
@@ -16,7 +16,7 @@
*/
#ifndef COLLATOR_COLLATOR_H
#define CCOLLATOR_COLLATOR_H
#define COLLATOR_COLLATOR_H
#include <php.h>
+3 -3
View File
@@ -800,9 +800,9 @@ PHP_FUNCTION(grapheme_extract)
{
char *str, *pstr;
UText ut = UTEXT_INITIALIZER;
size_t str_len;
zend_long size; /* maximum number of grapheme clusters, bytes, or characters (based on extract_type) to return */
zend_long lstart = 0; /* starting position in str in bytes */
int str_len;
long size; /* maximum number of grapheme clusters, bytes, or characters (based on extract_type) to return */
long lstart = 0; /* starting position in str in bytes */
int32_t start = 0;
long extract_type = GRAPHEME_EXTRACT_TYPE_COUNT;
UErrorCode status;
@@ -239,11 +239,12 @@ mbfl_memory_device_strcat(mbfl_memory_device *device, const char *psrc)
if ((device->pos + len) >= device->length) {
/* reallocate buffer */
int newlen = device->length + (len + MBFL_MEMORY_DEVICE_ALLOC_SIZE)*sizeof(unsigned char);
unsigned char *tmp;
if (newlen <= 0) {
/* overflow */
return -1;
}
unsigned char *tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char));
tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char));
if (tmp == NULL) {
return -1;
}
@@ -270,11 +271,12 @@ mbfl_memory_device_strncat(mbfl_memory_device *device, const char *psrc, int len
if ((device->pos + len) >= device->length) {
/* reallocate buffer */
int newlen = device->length + len + MBFL_MEMORY_DEVICE_ALLOC_SIZE;
unsigned char *tmp;
if (newlen <= 0) {
/* overflow */
return -1;
}
unsigned char *tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char));
tmp = (unsigned char *)mbfl_realloc((void *)device->buffer, newlen*sizeof(unsigned char));
if (tmp == NULL) {
return -1;
}
@@ -301,11 +303,12 @@ mbfl_memory_device_devcat(mbfl_memory_device *dest, mbfl_memory_device *src)
if ((dest->pos + src->pos) >= dest->length) {
/* reallocate buffer */
int newlen = dest->length + src->pos + MBFL_MEMORY_DEVICE_ALLOC_SIZE;
unsigned char *tmp;
if (newlen <= 0) {
/* overflow */
return -1;
}
unsigned char *tmp = (unsigned char *)mbfl_realloc((void *)dest->buffer, newlen*sizeof(unsigned char));
tmp = (unsigned char *)mbfl_realloc((void *)dest->buffer, newlen*sizeof(unsigned char));
if (tmp == NULL) {
return -1;
}
+10 -6
View File
@@ -1425,14 +1425,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
break;
case OP_EXACT1: MOP_IN(OP_EXACT1);
#if 0
DATA_ENSURE(1);
if (*p != *s) goto fail;
p++; s++;
#endif
if (*p != *s++) goto fail;
DATA_ENSURE(0);
p++;
MOP_OUT;
break;
@@ -3128,6 +3123,8 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
}
else {
UChar *q = p + reg->dmin;
if (q >= end) return 0; /* fail */
while (p < q) p += enclen(reg->enc, p);
}
}
@@ -3208,7 +3205,13 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
else {
if (reg->dmax != ONIG_INFINITE_DISTANCE) {
*low = p - reg->dmax;
if (*low > s) {
if (p - str < reg->dmax) {
*low = (UChar* )str;
if (low_prev)
*low_prev = onigenc_get_prev_char_head(reg->enc, str, *low);
}
else {
if (*low > s) {
*low = onigenc_get_right_adjust_char_head_with_prev(reg->enc, s,
*low, (const UChar** )low_prev);
if (low_prev && IS_NULL(*low_prev))
@@ -3221,6 +3224,7 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
(pprev ? pprev : str), *low);
}
}
}
}
/* no needs to adjust *high, *high is used as range check only */
*high = p - reg->dmin;
+9 -3
View File
@@ -3064,7 +3064,7 @@ fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
PUNFETCH;
prev = p;
num = scan_unsigned_octal_number(&p, end, 3, enc);
if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
if (num < 0 || num >= 256) return ONIGERR_TOO_BIG_NUMBER;
if (p == prev) { /* can't read nothing. */
num = 0; /* but, it's not error */
}
@@ -3436,7 +3436,7 @@ fetch_token(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env)
if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) {
prev = p;
num = scan_unsigned_octal_number(&p, end, (c == '0' ? 2:3), enc);
if (num < 0) return ONIGERR_TOO_BIG_NUMBER;
if (num < 0 || num >= 256) return ONIGERR_TOO_BIG_NUMBER;
if (p == prev) { /* can't read nothing. */
num = 0; /* but, it's not error */
}
@@ -4068,7 +4068,9 @@ next_state_class(CClassNode* cc, OnigCodePoint* vs, enum CCVALTYPE* type,
}
}
*state = CCS_VALUE;
if (*state != CCS_START)
*state = CCS_VALUE;
*type = CCV_CLASS;
return 0;
}
@@ -4084,7 +4086,11 @@ next_state_val(CClassNode* cc, OnigCodePoint *vs, OnigCodePoint v,
switch (*state) {
case CCS_VALUE:
if (*type == CCV_SB)
{
if (*vs > 0xff)
return ONIGERR_INVALID_CODE_POINT_VALUE;
BITSET_SET_BIT(cc->bs, (int )(*vs));
}
else if (*type == CCV_CODE_POINT) {
r = add_code_range(&(cc->mbuf), env, *vs, *vs);
if (r < 0) return r;
+1 -1
View File
@@ -89,7 +89,7 @@ static php_stream_filter_status_t php_mcrypt_filter(
php_stream_bucket_delref(bucket TSRMLS_CC);
} else {
/* Stream cipher */
php_stream_bucket_make_writeable(bucket TSRMLS_CC);
bucket = php_stream_bucket_make_writeable(bucket TSRMLS_CC);
if (data->encrypt) {
mcrypt_generic(data->module, bucket->buf, bucket->buflen);
} else {
+23
View File
@@ -0,0 +1,23 @@
--TEST--
Bug #72535 arcfour encryption stream filter crashes php
--SKIPIF--
<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
--FILE--
<?php
$passphrase = 'My secret';
$plaintext = 'Secret secret secret data';
$iv = substr(md5('iv' . $passphrase, true), 0, 8);
$key = substr(md5('pass1' . $passphrase, true) .
md5('pass2' . $passphrase, true), 0, 24);
$opts = array('iv' => $iv, 'key' => $key, 'mode' => 'stream');
$expected = substr($plaintext . $plaintext, 0, 48);
$fp = fopen('php://memory', 'wb+');
stream_filter_append($fp, 'mcrypt.arcfour', STREAM_FILTER_WRITE, $opts);
fwrite($fp, $plaintext);
?>
==NOCRASH==
--EXPECT--
==NOCRASH==
+3 -3
View File
@@ -4982,15 +4982,15 @@ PHP_FUNCTION(openssl_seal)
buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(&ctx));
EVP_CIPHER_CTX_cleanup(&ctx);
if (!EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) || !EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) {
if (EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) <= 0 ||
!EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len) ||
!EVP_SealFinal(&ctx, buf + len1, &len2)) {
RETVAL_FALSE;
efree(buf);
EVP_CIPHER_CTX_cleanup(&ctx);
goto clean_exit;
}
EVP_SealFinal(&ctx, buf + len1, &len2);
if (len1 + len2 > 0) {
zval_dtor(sealdata);
buf[len1 + len2] = '\0';
+27
View File
@@ -0,0 +1,27 @@
-----BEGIN CERTIFICATE-----
MIIEoDCCBAmgAwIBAgIBJzANBgkqhkiG9w0BAQQFADCBkDELMAkGA1UEFhMCUk8x
EDAOBgNVBAgTB1JvbWFuaWExEDAOBgNVBAcTB0NyYWlvdmExDzANBgNVBAoTBlNl
cmdpdTETMBEGA1UECxMKU2VyZ2l1IFNSTDESMBAGA1UEAxMJU2VyZ2l1IENBMSMw
IQYJKoZIhvcNAQkBFhRuX3NlcmdpdUBob3RtYWlsLmNvbTAeFw0wNDA1MTQxMzM0
NTZaFw0wNTA1MTQxMzM0NTZaMIGaMQswCQYDVQQGEwJSTzEQMA4GA1UECBMHUm9t
YW5pYTEQMA4GA1UEBxMHQ3JhaW92YTETMBEGA1UEChMKU2VyZ2l1IFNSTDETMBEG
A1UECxMKU2VyZ2l1IFNSTDEYMBYGA1UEAxMPU2VyZ2l1IHBlcnNvbmFsMSMwIQYJ
KoZIhvcNAQkBFhRuX3NlcmdpdUBob3RtYWlsLmNvbTCBnzANBgkqhkiG9w0BAQEF
AAOBjQAwgYkCgYEApNj7XXz8T8FcLIWpBniPYom3QcT6T7u0xRPHqtqzj5oboBYp
DJe5d354/y0gJTpiLt8+fTrPgWXnbHm3pOHgXzTcX6Arani0GDU0/xDi4VkCRGcS
YqX2sJpcDzAbmK9UDMt3xf/O1B8AJan3RfO0Bm3ozTEPziLMkmsiYr5b/L4CAwEA
AaOCAfwwggH4MAkGA1UdEwQCMAAwNQYJYIZIAYb4QgENBCgWJkZvciBHcmlkIHVz
ZSBvbmx5OyByZXF1ZXN0IHRhZyB1c2VyVGFnMBEGCWCGSAGG+EIBAQQEAwIF4DA/
BgNVHR8EODA2MDSgMqAwhi5odHRwOi8vbW9iaWxlLmJsdWUtc29mdHdhcmUucm86
OTAvY2EvY3JsLnNodG1sMDUGCWCGSAGG+EIBCAQoFiZodHRwOi8vbW9iaWxlLmJs
dWUtc29mdHdhcmUucm86OTAvcHViLzAhBgNVHREEGjAYgRZzZXJnaXVAYmx1ZXNv
ZnR3YXJlLnJvMB0GA1UdDgQWBBSwp//5QRXeIzm93TEPl6CyonTg/DCBpwYDVR0j
BIGfMIGcoYGWpIGTMIGQMQswCQYDVQQGEwJSTzEQMA4GA1UECBMHUm9tYW5pYTEQ
MA4GA1UEBxMHQ3JhaW92YTEPMA0GA1UEChMGU2VyZ2l1MRMwEQYDVQQLEwpTZXJn
aXUgU1JMMRIwEAYDVQQDEwlTZXJnaXUgQ0ExIzAhBgkqhkiG9w0BCQEWFG5fc2Vy
Z2l1QGhvdG1haWwuY29tggEAMAsGA1UdDwQEAwIE8DAjBglghkgBhvhCAQIEFhYU
aHR0cDovLzYyLjIzMS45OC41Mi8wCwYDKgMEBAQ+52I0MA0GCSqGSIb3DQEBBAUA
A4GBAIBIOJ+iiLyQfNJEY+IMefayQea0nmuXYY+F+L1DFjSC7xChytgYoPNnKkhh
3dWPtxbswiqKYUnGi6y3Hi4UhDsOaDW29t2S305hSc2qgjOiNtRYQIVYQ8EHG1k7
Fl63S7uCOhnVJt+4MnUK1N6/pwgsp+Z2GvEsDG1qCKnvNpf6
-----END CERTIFICATE-----
+17
View File
@@ -0,0 +1,17 @@
--TEST--
Bug #74651: negative-size-param (-1) in memcpy in zif_openssl_seal()
--SKIPIF--
<?php
if (!extension_loaded("openssl")) die("skip openssl not loaded");
?>
--FILE--
<?php
$inputstr = file_get_contents(__DIR__ . "/74651.pem");
$pub_key_id = openssl_get_publickey($inputstr);
var_dump($pub_key_id);
var_dump(openssl_seal($inputstr, $sealed, $ekeys, array($pub_key_id, $pub_key_id), 'AES-128-ECB'));
?>
--EXPECTF--
resource(%d) of type (OpenSSL key)
bool(false)
+6 -1
View File
@@ -7274,7 +7274,12 @@ for (;; ptr++)
so far in order to get the number. If the name is not found, leave
the value of recno as 0 for a forward reference. */
else
/* This patch (removing "else") fixes a problem when a reference is
to multiple identically named nested groups from within the nest.
Once again, it is not the "proper" fix, and it results in an
over-allocation of memory. */
/* else */
{
ng = cd->named_groups;
for (i = 0; i < cd->names_found; i++, ng++)
+1 -1
View File
@@ -7307,7 +7307,7 @@ if (opcode == OP_COND || opcode == OP_SCOND)
if (*matchingpath == OP_FAIL)
stacksize = 0;
if (*matchingpath == OP_RREF)
else if (*matchingpath == OP_RREF)
{
stacksize = GET2(matchingpath, 1);
if (common->currententry == NULL)
+10
View File
@@ -0,0 +1,10 @@
--TEST--
CVE-2016-1283, see bug #75207
--FILE--
<?php
preg_match("/š(?:F?+(?:^(?(R)a+\"){99}-))(?J)(?'R'(?'R'<((?'RR'(?'R'\){97)?J)?J)(?'R'(?'R'\){99|(:(?|(?'R')(\k'R')|((?'R')))H'R'R)(H'R))))))/", "*b\dc");
?>
==DONE==
--EXPECTF--
Warning: preg_match(): Compilation failed: unmatched parentheses at offset %d in %s on line %d
==DONE==
@@ -16,6 +16,17 @@ if (count($tmp) < 2)
if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
die("skip Test cannot be run against remote database server");
$stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'");
if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) {
if (!is_writable($row['value']))
die("skip secure_file_priv directory not writable: {$row['value']}");
$filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv";
if (file_exists($filename) && !is_writable($filename))
die("skip {$filename} not writable");
}
?>
--FILE--
<?php
@@ -16,6 +16,17 @@ if (count($tmp) < 2)
if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
die("skip Test cannot be run against remote database server");
$stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'");
if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) {
if (!is_writable($row['value']))
die("skip secure_file_priv directory not writable: {$row['value']}");
$filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv";
if (file_exists($filename) && !is_writable($filename))
die("skip {$filename} not writable");
}
?>
--FILE--
<?php
@@ -115,4 +126,4 @@ Warning: PDOStatement::execute(): SQLSTATE[HY000]: General error: %s in %s on li
1 => %d,
2 => %s,
)
done!
done!
+3 -4
View File
@@ -981,7 +981,6 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
/* if the alias is stored we enforce it (implicit overrides explicit) */
if (alias && alias_len && (alias_len != (int)tmp_len || strncmp(alias, buffer, tmp_len)))
{
buffer[tmp_len] = '\0';
php_stream_close(fp);
if (signature) {
@@ -989,7 +988,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
}
if (error) {
spprintf(error, 0, "cannot load phar \"%s\" with implicit alias \"%s\" under different alias \"%s\"", fname, buffer, alias);
spprintf(error, 0, "cannot load phar \"%s\" with implicit alias \"%.*s\" under different alias \"%s\"", fname, tmp_len, buffer, alias);
}
efree(savebuf);
@@ -1055,7 +1054,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
entry.is_persistent = mydata->is_persistent;
for (manifest_index = 0; manifest_index < manifest_count; ++manifest_index) {
if (buffer + 4 > endbuffer) {
if (buffer + 28 > endbuffer) {
MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)")
}
@@ -1069,7 +1068,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
entry.manifest_pos = manifest_index;
}
if (entry.filename_len + 20 > endbuffer - buffer) {
if (entry.filename_len > endbuffer - buffer - 24) {
MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)");
}
+1 -1
View File
@@ -74,7 +74,7 @@ if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
+2 -2
View File
@@ -22,13 +22,13 @@ static inline void phar_get_stub(const char *index_php, const char *web, size_t
{
static const char newstub0[] = "<?php\n\n$web = '";
static const char newstub1_0[] = "';\n\nif (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {\nPhar::interceptFileFuncs();\nset_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());\nPhar::webPhar(null, $web);\ninclude 'phar://' . __FILE__ . '/' . Extract_Phar::START;\nreturn;\n}\n\nif (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {\nExtract_Phar::go(true);\n$mimes = array(\n'phps' => 2,\n'c' => 'text/plain',\n'cc' => 'text/plain',\n'cpp' => 'text/plain',\n'c++' => 'text/plain',\n'dtd' => 'text/plain',\n'h' => 'text/plain',\n'log' => 'text/plain',\n'rng' => 'text/plain',\n'txt' => 'text/plain',\n'xsd' => 'text/plain',\n'php' => 1,\n'inc' => 1,\n'avi' => 'video/avi',\n'bmp' => 'image/bmp',\n'css' => 'text/css',\n'gif' => 'image/gif',\n'htm' => 'text/html',\n'html' => 'text/html',\n'htmls' => 'text/html',\n'ico' => 'image/x-ico',\n'jpe' => 'image/jpeg',\n'jpg' => 'image/jpeg',\n'jpeg' => 'image/jpeg',\n'js' => 'application/x-javascript',\n'midi' => 'audio/midi',\n'mid' => 'audio/midi',\n'mod' => 'audio/mod',\n'mov' => 'movie/quicktime',\n'mp3' => 'audio/mp3',\n'mpg' => 'video/mpeg',\n'mpeg' => 'video/mpeg',\n'pdf' => 'application/pdf',\n'png' => 'image/png',\n'swf' => 'application/shockwave-flash',\n'tif' => 'image/tiff',\n'tiff' => 'image/tiff',\n'wav' => 'audio/wav',\n'xbm' => 'image/xbm',\n'xml' => 'text/xml',\n);\n\nheader(\"Cache-Control: no-cache, must-revalidate\");\nheader(\"Pragma: no-cache\");\n\n$basename = basename(__FILE__);\nif (!strpos($_SERVER['REQUEST_URI'], $basename)) {\nchdir(Extract_Phar::$temp);\ninclude $web;\nreturn;\n}\n$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));\nif (!$pt || $pt == '/') {\n$pt = $web;\nheader('HTTP/1.1 301 Moved Permanently');\nheader('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);\nexit;\n}\n$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);\nif (!$a || strlen(dirname($a)) < strlen(";
static const char newstub1_1[] = "Extract_Phar::$temp)) {\nheader('HTTP/1.0 404 Not Found');\necho \"<html>\\n <head>\\n <title>File Not Found<title>\\n </head>\\n <body>\\n <h1>404 - File \", $pt, \" Not Found</h1>\\n </body>\\n</html>\";\nexit;\n}\n$b = pathinfo($a);\nif (!isset($b['extension'])) {\nheader('Content-Type: text/plain');\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\nif (isset($mimes[$b['extension']])) {\nif ($mimes[$b['extension']] === 1) {\ninclude $a;\nexit;\n}\nif ($mimes[$b['extension']] === 2) {\nhighlight_file($a);\nexit;\n}\nheader('Content-Type: ' .$mimes[$b['extension']]);\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\n}\n\nclass Extract_Phar\n{\nstatic $temp;\nstatic $origdir;\nconst GZ = 0x1000;\nconst BZ2 = 0x2000;\nconst MASK = 0x3000;\nconst START = '";
static const char newstub1_1[] = "Extract_Phar::$temp)) {\nheader('HTTP/1.0 404 Not Found');\necho \"<html>\\n <head>\\n <title>File Not Found<title>\\n </head>\\n <body>\\n <h1>404 - File Not Found</h1>\\n </body>\\n</html>\";\nexit;\n}\n$b = pathinfo($a);\nif (!isset($b['extension'])) {\nheader('Content-Type: text/plain');\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\nif (isset($mimes[$b['extension']])) {\nif ($mimes[$b['extension']] === 1) {\ninclude $a;\nexit;\n}\nif ($mimes[$b['extension']] === 2) {\nhighlight_file($a);\nexit;\n}\nheader('Content-Type: ' .$mimes[$b['extension']]);\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\n}\n\nclass Extract_Phar\n{\nstatic $temp;\nstatic $origdir;\nconst GZ = 0x1000;\nconst BZ2 = 0x2000;\nconst MASK = 0x3000;\nconst START = '";
static const char newstub2[] = "';\nconst LEN = ";
static const char newstub3_0[] = ";\n\nstatic function go($return = false)\n{\n$fp = fopen(__FILE__, 'rb');\nfseek($fp, self::LEN);\n$L = unpack('V', $a = (binary)fread($fp, 4));\n$m = (binary)'';\n\ndo {\n$read = 8192;\nif ($L[1] - strlen($m) < 8192) {\n$read = $L[1] - strlen($m);\n}\n$last = (binary)fread($fp, $read);\n$m .= $last;\n} while (strlen($last) && strlen($m) < $L[1]);\n\nif (strlen($m) < $L[1]) {\ndie('ERROR: manifest length read was \"' .\nstrlen($m) .'\" should be \"' .\n$L[1] . '\"');\n}\n\n$info = self::_unpack($m);\n$f = $info['c'];\n\nif ($f & self::GZ) {\nif (!function_exists('gzinflate')) {\ndie('Error: zlib extension is not enabled -' .\n' gzinflate() function needed for zlib-compressed .phars');\n}\n}\n\nif ($f & self::BZ2) {\nif (!function_exists('bzdecompress')) {\ndie('Error: bzip2 extension is not enabled -' .\n' bzdecompress() function needed for bz2-compressed .phars');\n}\n}\n\n$temp = self::tmpdir();\n\nif (!$temp || !is_writable($temp)) {\n$sessionpath = session_save_path();\nif (strpos ($sessionpath, \";\") !== false)\n$sessionpath = substr ($sessionpath, strpos ($sessionpath, \";\")+1);\nif (!file_exists($sessionpath) || !is_dir($sessionpath)) {\ndie('Could not locate temporary directory to extract phar');\n}\n$temp = $sessionpath;\n}\n\n$temp .= '/pharextract/'.basename(__FILE__, '.phar');\nself::$temp = $temp;\nself::$origdir = getcwd();\n@mkdir($temp, 0777, true);\n$temp = realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());\n@mkdir($temp, 0777, true);\n@file_put_contents($temp . '/' . md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a = !file_exists(dirname($temp . '/' . $path));\n@mkdir(dirname($temp . '/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1] == '/') {\n@mkdir($temp . '/' . $path, 0777);\n} else {\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));\n@chmod($temp . '/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclude self::ST";
static const char newstub3_1[] = "ART;\n}\n}\n\nstatic function tmpdir()\n{\nif (strpos(PHP_OS, 'WIN') !== false) {\nif ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {\nreturn $var;\n}\nif (is_dir('/temp') || mkdir('/temp')) {\nreturn realpath('/temp');\n}\nreturn false;\n}\nif ($var = getenv('TMPDIR')) {\nreturn $var;\n}\nreturn realpath('/tmp');\n}\n\nstatic function _unpack($m)\n{\n$info = unpack('V', substr($m, 0, 4));\n $l = unpack('V', substr($m, 10, 4));\n$m = substr($m, 14 + $l[1]);\n$s = unpack('V', substr($m, 0, 4));\n$o = 0;\n$start = 4 + $s[1];\n$ret['c'] = 0;\n\nfor ($i = 0; $i < $info[1]; $i++) {\n $len = unpack('V', substr($m, $start, 4));\n$start += 4;\n $savepath = substr($m, $start, $len[1]);\n$start += $len[1];\n $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));\n$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]\n& 0xffffffff);\n$ret['m'][$savepath][7] = $o;\n$o += $ret['m'][$savepath][2];\n$start += 24 + $ret['m'][$savepath][5];\n$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;\n}\nreturn $ret;\n}\n\nstatic function extractFile($path, $entry, $fp)\n{\n$data = '';\n$c = $entry[2];\n\nwhile ($c) {\nif ($c < 8192) {\n$data .= @fread($fp, $c);\n$c = 0;\n} else {\n$c -= 8192;\n$data .= @fread($fp, 8192);\n}\n}\n\nif ($entry[4] & self::GZ) {\n$data = gzinflate($data);\n} elseif ($entry[4] & self::BZ2) {\n$data = bzdecompress($data);\n}\n\nif (strlen($data) != $entry[0]) {\ndie(\"Invalid internal .phar file (size error \" . strlen($data) . \" != \" .\n$stat[7] . \")\");\n}\n\nif ($entry[3] != sprintf(\"%u\", crc32((binary)$data) & 0xffffffff)) {\ndie(\"Invalid internal .phar file (checksum error)\");\n}\n\nreturn $data;\n}\n\nstatic function _removeTmpFiles($temp, $origdir)\n{\nchdir($temp);\n\nforeach (glob('*') as $f) {\nif (file_exists($f)) {\nis_dir($f) ? @rmdir($f) : @unlink($f);\nif (file_exists($f) && is_dir($f)) {\nself::_removeTmpFiles($f, getcwd());\n}\n}\n}\n\n@rmdir($temp);\nclearstatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__HALT_COMPIL";
static const char newstub3_2[] = "ER(); ?>";
static const int newstub_len = 6665;
static const int newstub_len = 6655;
*len = spprintf(stub, name_len + web_len + newstub_len, "%s%s%s%s%s%s%d%s%s%s", newstub0, web, newstub1_0, newstub1_1, index_php, newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1, newstub3_2);
}
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
--TEST--
Phar: PHP bug #73764: Crash while loading hostile phar archive
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--FILE--
<?php
chdir(__DIR__);
try {
$p = Phar::LoadPhar('bug73764.phar', 'alias.phar');
echo "OK\n";
} catch(PharException $e) {
echo $e->getMessage();
}
?>
--EXPECTF--
internal corruption of phar "%sbug73764.phar" (truncated manifest entry)
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
--TEST--
Phar: PHP bug #73768: Memory corruption when loading hostile phar
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--FILE--
<?php
chdir(__DIR__);
try {
$p = Phar::LoadPhar('bug73768.phar', 'alias.phar');
echo "OK\n";
} catch(PharException $e) {
echo $e->getMessage();
}
?>
--EXPECTF--
cannot load phar "%sbug73768.phar" with implicit alias "" under different alias "alias.phar"
@@ -18,5 +18,5 @@ echo strlen($p2->getStub()),"\n";
echo "ok\n";
__HALT_COMPILER(); ?>
"
6685
6675
ok
+1 -1
View File
@@ -29,7 +29,7 @@ unlink(dirname(__FILE__) . '/brandnewphar.phar');
__HALT_COMPILER();
?>
--EXPECT--
int(6683)
int(6673)
string(200) "<?php
function __autoload($class)
{
+1 -1
View File
@@ -123,7 +123,7 @@ NULL
bool(true)
bool(false)
bool(false)
int(6683)
int(6673)
NULL
================= convertToZip() =====================
bool(false)
+1 -1
View File
@@ -32,7 +32,7 @@ __HALT_COMPILER();
unlink(dirname(__FILE__) . '/brandnewphar.phar');
?>
--EXPECT--
int(6683)
int(6673)
string(200) "<?php
function __autoload($class)
{
+11 -11
View File
@@ -34,7 +34,7 @@ echo $e->getMessage() . "\n";
?>
===DONE===
--EXPECT--
string(6683) "<?php
string(6673) "<?php
$web = 'index.php';
@@ -110,7 +110,7 @@ exit;
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
@@ -144,7 +144,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'index.php';
const LEN = 6685;
const LEN = 6675;
static function go($return = false)
{
@@ -328,7 +328,7 @@ Extract_Phar::go();
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
string(6694) "<?php
string(6684) "<?php
$web = 'index.php';
@@ -404,7 +404,7 @@ exit;
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
@@ -438,7 +438,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
const LEN = 6696;
const LEN = 6686;
static function go($return = false)
{
@@ -622,7 +622,7 @@ Extract_Phar::go();
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
int(7074)
int(7064)
============================================================================
============================================================================
Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
@@ -630,7 +630,7 @@ Illegal filename passed in for stub creation, was 401 characters long, and only
============================================================================
============================================================================
============================================================================
string(6696) "<?php
string(6686) "<?php
$web = 'the/web.php';
@@ -706,7 +706,7 @@ exit;
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
@@ -740,7 +740,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
const LEN = 6698;
const LEN = 6688;
static function go($return = false)
{
@@ -924,6 +924,6 @@ Extract_Phar::go();
__HALT_COMPILER(); ?>"
============================================================================
============================================================================
int(7074)
int(7064)
Illegal web filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
===DONE===
+2 -2
View File
@@ -70,8 +70,8 @@ var_dump($phar->getAlias());
Entry .phar/stub.php does not exist
Entry .phar/alias.txt does not exist
Cannot set stub ".phar/stub.php" directly in phar "%sphar_offset_check.phar.php", use setStub
int(6685)
int(6685)
int(6675)
int(6675)
Cannot set alias ".phar/alias.txt" directly in phar "%sphar_offset_check.phar.php", use setAlias
string(5) "susan"
string(5) "susan"
+10 -10
View File
@@ -54,7 +54,7 @@ try {
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
?>
--EXPECT--
string(6685) "<?php
string(6675) "<?php
$web = 'index.php';
@@ -130,7 +130,7 @@ exit;
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
@@ -164,7 +164,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'index.php';
const LEN = 6685;
const LEN = 6675;
static function go($return = false)
{
@@ -349,7 +349,7 @@ __HALT_COMPILER(); ?>
"
============================================================================
============================================================================
string(6696) "<?php
string(6686) "<?php
$web = 'index.php';
@@ -425,7 +425,7 @@ exit;
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
@@ -459,7 +459,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
const LEN = 6696;
const LEN = 6686;
static function go($return = false)
{
@@ -644,7 +644,7 @@ __HALT_COMPILER(); ?>
"
============================================================================
============================================================================
string(6698) "<?php
string(6688) "<?php
$web = 'the/web.php';
@@ -720,7 +720,7 @@ exit;
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
@@ -754,7 +754,7 @@ const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'my/custom/thingy.php';
const LEN = 6698;
const LEN = 6688;
static function go($return = false)
{
@@ -939,6 +939,6 @@ __HALT_COMPILER(); ?>
"
============================================================================
============================================================================
int(7076)
int(7066)
Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
===DONE===
+3 -3
View File
@@ -47,12 +47,12 @@ __HALT_COMPILER();
?>
--EXPECT--
bool(false)
int(6683)
int(6673)
bool(true)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
bool(true)
int(6683)
int(6673)
bool(true)
int(6683)
int(6673)
===DONE===
+3 -3
View File
@@ -49,14 +49,14 @@ __HALT_COMPILER();
?>
--EXPECT--
bool(false)
int(6683)
int(6673)
bool(true)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
bool(true)
int(4096)
int(6683)
int(6673)
bool(true)
bool(true)
int(6683)
int(6673)
===DONE===
+3 -3
View File
@@ -49,14 +49,14 @@ __HALT_COMPILER();
?>
--EXPECT--
bool(false)
int(6683)
int(6673)
bool(true)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
bool(true)
int(8192)
int(6683)
int(6673)
bool(true)
bool(true)
int(6683)
int(6673)
===DONE===
+3 -3
View File
@@ -54,7 +54,7 @@ __HALT_COMPILER();
?>
--EXPECT--
bool(false)
int(6683)
int(6673)
string(2) "hi"
bool(true)
string(60) "<?php // tar-based phar archive stub file
@@ -62,10 +62,10 @@ __HALT_COMPILER();"
string(2) "hi"
bool(true)
int(4096)
int(6683)
int(6673)
string(2) "hi"
bool(true)
bool(true)
int(6683)
int(6673)
string(2) "hi"
===DONE===
+3 -3
View File
@@ -46,12 +46,12 @@ __HALT_COMPILER();
?>
--EXPECT--
bool(false)
int(6683)
int(6673)
bool(true)
string(60) "<?php // zip-based phar archive stub file
__HALT_COMPILER();"
bool(true)
int(6683)
int(6673)
bool(true)
int(6683)
int(6673)
===DONE===
+4
View File
@@ -2184,6 +2184,10 @@ static void php_sqlite3_result_object_free_storage(void *object TSRMLS_DC) /* {{
}
if (intern->stmt_obj_zval) {
if (intern->stmt_obj->initialised) {
sqlite3_reset(intern->stmt_obj->stmt);
}
if (intern->is_prepared_statement == 0) {
zval_dtor(intern->stmt_obj_zval);
FREE_ZVAL(intern->stmt_obj_zval);
-32
View File
@@ -1,32 +0,0 @@
--TEST--
Bug #73530 (Unsetting result set may reset other result set)
--SKIPIF--
<?php
if (!extension_loaded('sqlite3')) die('skip sqlite3 extension not available');
?>
--FILE--
<?php
$db = new SQLite3(':memory:');
$db->exec("CREATE TABLE foo (num int)");
$db->exec("INSERT INTO foo VALUES (0)");
$db->exec("INSERT INTO foo VALUES (1)");
$stmt = $db->prepare("SELECT * FROM foo WHERE NUM = ?");
$stmt->bindValue(1, 0, SQLITE3_INTEGER);
$res1 = $stmt->execute();
$res1->finalize();
$stmt->clear();
$stmt->reset();
$stmt->bindValue(1, 1, SQLITE3_INTEGER);
$res2 = $stmt->execute();
while ($row = $res2->fetchArray(SQLITE3_ASSOC)) {
var_dump($row);
unset($res1);
}
?>
===DONE===
--EXPECT--
array(1) {
["num"]=>
int(1)
}
===DONE===
+2 -2
View File
@@ -737,9 +737,9 @@ finish:
tmp_line, response_code);
}
}
if (tmp_line[tmp_line_len - 1] == '\n') {
if (tmp_line_len >= 1 && tmp_line[tmp_line_len - 1] == '\n') {
--tmp_line_len;
if (tmp_line[tmp_line_len - 1] == '\r') {
if (tmp_line_len >= 1 &&tmp_line[tmp_line_len - 1] == '\r') {
--tmp_line_len;
}
}
+32
View File
@@ -0,0 +1,32 @@
--TEST--
Bug #75981 (stack-buffer-overflow while parsing HTTP response)
--INI--
allow_url_fopen=1
--SKIPIF--
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
--FILE--
<?php
require 'server.inc';
$options = [
'http' => [
'protocol_version' => '1.1',
'header' => 'Connection: Close'
],
];
$ctx = stream_context_create($options);
$responses = [
"data://text/plain,000000000100\xA\xA"
];
$pid = http_server('tcp://127.0.0.1:12342', $responses);
echo @file_get_contents('http://127.0.0.1:12342/', false, $ctx);
http_server_kill($pid);
?>
DONE
--EXPECT--
DONE
+1 -1
View File
@@ -42,7 +42,7 @@ bool(false)
Notice: unserialize(): Error at offset 17 of 33 bytes in %sbug25378.php on line %d
bool(false)
Notice: unserialize(): Error at offset 33 of 32 bytes in %sbug25378.php on line %d
Notice: unserialize(): Error at offset 32 of 32 bytes in %sbug25378.php on line %d
bool(false)
Notice: unserialize(): Error at offset 2 of 13 bytes in %sbug25378.php on line %d
@@ -0,0 +1,63 @@
--TEST--
Bug #69425: Use After Free in unserialize()
--FILE--
<?php
// POC 1
class test
{
var $ryat;
function __wakeup()
{
$this->ryat = 1;
}
}
$data = unserialize('a:2:{i:0;O:4:"test":1:{s:4:"ryat";R:1;}i:1;i:2;}');
var_dump($data);
// POC 2
$data = unserialize('a:2:{i:0;O:12:"DateInterval":1:{s:1:"y";R:1;}i:1;i:2;}');
var_dump($data);
?>
--EXPECT--
int(1)
array(2) {
[0]=>
object(DateInterval)#1 (15) {
["y"]=>
int(-1)
["m"]=>
int(-1)
["d"]=>
int(-1)
["h"]=>
int(-1)
["i"]=>
int(-1)
["s"]=>
int(-1)
["weekday"]=>
int(-1)
["weekday_behavior"]=>
int(-1)
["first_last_day_of"]=>
int(-1)
["invert"]=>
int(0)
["days"]=>
int(-1)
["special_type"]=>
int(0)
["special_amount"]=>
int(-1)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
[1]=>
int(2)
}
@@ -0,0 +1,30 @@
--TEST--
Bug #70213: Unserialize context shared on double class lookup
--FILE--
<?php
ini_set('unserialize_callback_func', 'evil');
function evil() {
function __autoload($arg) {
var_dump(unserialize('R:1;'));
}
}
var_dump(unserialize('a:2:{i:0;i:42;i:1;O:4:"evil":0:{}}'));
?>
--EXPECTF--
Notice: unserialize(): Error at offset 4 of 4 bytes in %s on line %d
bool(false)
Warning: unserialize(): Function evil() hasn't defined the class it was called for in %s on line %d
array(2) {
[0]=>
int(42)
[1]=>
object(__PHP_Incomplete_Class)#1 (1) {
["__PHP_Incomplete_Class_Name"]=>
string(4) "evil"
}
}
@@ -0,0 +1,39 @@
--TEST--
Bug #70513: GMP Deserialization Type Confusion Vulnerability
--SKIPIF--
<?php if (!extension_loaded('gmp')) die('skip requires gmp');
--FILE--
<?php
class obj
{
var $ryat;
function __wakeup()
{
$this->ryat = 1;
}
}
$obj = new stdClass;
$obj->aa = 1;
$obj->bb = 2;
$inner = 's:1:"1";a:3:{s:2:"aa";s:2:"hi";s:2:"bb";s:2:"hi";i:0;O:3:"obj":1:{s:4:"ryat";R:2;}}';
$exploit = 'a:1:{i:0;C:3:"GMP":'.strlen($inner).':{'.$inner.'}}';
$x = unserialize($exploit);
var_dump($x);
var_dump($obj);
?>
--EXPECT--
array(1) {
[0]=>
int(1)
}
object(stdClass)#1 (2) {
["aa"]=>
int(1)
["bb"]=>
int(2)
}
@@ -0,0 +1,64 @@
--TEST--
__wakeup should be able to add dynamic properties without affecting other dynamic properties
--FILE--
<?php
class Obj {
// Testing $this->a being a dynamic property.
function __construct($a) {
$this->a = $a;
}
public function __wakeup() {
echo "Calling __wakeup\n";
for ($i = 0; $i < 10000; $i++) {
$this->{'b' . $i} = 42;
}
}
}
function main() {
$obj = new stdClass();
$obj->test = 'foo';
$variable = [new Obj($obj), new Obj($obj)];
$serialized = serialize($variable);
printf("%s\n", $serialized);
$unserialized = unserialize($serialized);
for ($i = 0; $i < 10000; $i++) {
if ($unserialized[0]->{'b' . $i} !== 42) {
echo "Fail 0 b$i\n";
return;
}
if ($unserialized[1]->{'b' . $i} !== 42) {
echo "Fail 1 b$i\n";
return;
}
unset($unserialized[0]->{'b' . $i});
unset($unserialized[1]->{'b' . $i});
}
var_dump($unserialized);
}
main();
--EXPECTF--
a:2:{i:0;O:3:"Obj":1:{s:1:"a";O:8:"stdClass":1:{s:4:"test";s:3:"foo";}}i:1;O:3:"Obj":1:{s:1:"a";r:3;}}
Calling __wakeup
Calling __wakeup
array(2) {
[0]=>
object(Obj)#%d (1) {
["a"]=>
object(stdClass)#%d (1) {
["test"]=>
string(3) "foo"
}
}
[1]=>
object(Obj)#%d (1) {
["a"]=>
object(stdClass)#%d (1) {
["test"]=>
string(3) "foo"
}
}
}
@@ -0,0 +1,32 @@
--TEST--
__wakeup can replace a copy of the object referring to the root node.
--FILE--
<?php
/* This bug never happened, but adding this test to make sure that further changes to unserialize don't allow freeing the root in __wakeup. */
class Obj {
function __construct($a) {
$this->a = $a;
}
public function __wakeup() {
echo "Calling __wakeup\n";
$this->a = "replaced";
}
}
$a = new stdClass();
$a->obj = new Obj($a);;
$serialized = serialize($a);
printf("%s\n", $serialized);
$unserialized = unserialize($serialized);
var_dump($unserialized);
--EXPECTF--
O:8:"stdClass":1:{s:3:"obj";O:3:"Obj":1:{s:1:"a";r:1;}}
Calling __wakeup
object(stdClass)#%d (1) {
["obj"]=>
object(Obj)#%d (1) {
["a"]=>
string(8) "replaced"
}
}
@@ -0,0 +1,51 @@
--TEST--
__wakeup should be able to modify dynamic properties without affecting copies of those properties
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip json_encode needed"; ?>
--FILE--
<?php
class Obj {
// Testing $this->a being a dynamic property.
function __construct($a) {
$this->a = $a;
}
public function __wakeup() {
echo "Calling __wakeup " . json_encode($this->a) . "\n";
$this->a = "roh";
}
}
function main() {
$obj = new stdClass();
$obj->c = null;
$variable = [new Obj($obj), new Obj($obj), $obj];
$serialized = serialize($variable);
printf("%s\n", $serialized);
$unserialized = unserialize($serialized);
var_dump($unserialized);
}
main();
--EXPECTF--
a:3:{i:0;O:3:"Obj":1:{s:1:"a";O:8:"stdClass":1:{s:1:"c";N;}}i:1;O:3:"Obj":1:{s:1:"a";r:3;}i:2;r:3;}
Calling __wakeup {"c":null}
Calling __wakeup {"c":null}
array(3) {
[0]=>
object(Obj)#%d (1) {
["a"]=>
string(3) "roh"
}
[1]=>
object(Obj)#%d (1) {
["a"]=>
string(3) "roh"
}
[2]=>
object(stdClass)#%d (1) {
["c"]=>
NULL
}
}
@@ -0,0 +1,18 @@
--TEST--
Bug #72731: Type Confusion in Object Deserialization
--FILE--
<?php
class obj {
var $ryat;
function __wakeup() {
$this->ryat = 0x1122334455;
}
}
$poc = 'O:8:"stdClass":1:{i:0;O:3:"obj":1:{s:4:"ryat";R:1;}}';
var_dump(unserialize($poc));
?>
--EXPECTF--
%s(73588229205)
@@ -0,0 +1,17 @@
--TEST--
Bug #73092: Unserialize use-after-free when resizing object's properties hash table
--FILE--
<?php
class foo {
function __wakeup() {
$this->{'x'} = 1;
}
}
unserialize('a:3:{i:0;O:3:"foo":8:{i:0;i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:5;i:6;i:6;i:7;i:7;}i:1;s:263:"'.str_repeat("\06", 263).'";i:2;r:3;}');
?>
===DONE===
--EXPECT--
===DONE===
@@ -0,0 +1,49 @@
--TEST--
Bug #73092: Unserialize use-after-free when resizing object's properties hash table (2)
--FILE--
<?php
class foo {
public $x;
function __wakeup() {
var_dump($this->x);
}
}
unserialize('a:3:{i:0;O:3:"foo":1:{s:1:"x";O:12:"DateInterval":1:{i:0;i:0;}}i:1;s:263:"'.str_repeat("\06", 263).'";i:2;r:4;}}');
?>
--EXPECTF--
object(DateInterval)#%d (16) {
["0"]=>
int(0)
["y"]=>
int(-1)
["m"]=>
int(-1)
["d"]=>
int(-1)
["h"]=>
int(-1)
["i"]=>
int(-1)
["s"]=>
int(-1)
["weekday"]=>
int(-1)
["weekday_behavior"]=>
int(-1)
["first_last_day_of"]=>
int(-1)
["invert"]=>
int(0)
["days"]=>
int(-1)
["special_type"]=>
int(0)
["special_amount"]=>
int(-1)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
@@ -0,0 +1,31 @@
--TEST--
Bug #73367: Create an Unexpected Object and Don't Invoke __wakeup() in Deserialization
--FILE--
<?php
class obj {
var $ryat;
function __wakeup() {
$this->ryat = null;
echo "wakeup\n";
throw new Exception("Not a serializable object");
}
function __destruct() {
echo "dtor\n";
if ($this->ryat == 1) {
echo "dtor ryat==1\n";
}
}
}
$poc = 'O:3:"obj":2:{s:4:"ryat";i:1;i:0;O:3:"obj":1:{s:4:"ryat";R:1;}}';
try {
unserialize($poc);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
wakeup
Not a serializable object
@@ -0,0 +1,21 @@
--TEST--
Bug #73367: Create an Unexpected Object and Don't Invoke __wakeup() in Deserialization (2)
--FILE--
<?php
class obj {
var $ryat;
function __wakeup() {
$this->ryat = null;
$this->foo = 'bar'; // $this should still be live here
echo "wakeup\n";
}
}
$poc = 'O:3:"obj":2:{s:4:"ryat";i:1;i:0;O:3:"obj":1:{s:4:"ryat";R:1;}}';
unserialize($poc);
?>
--EXPECT--
wakeup
wakeup
@@ -0,0 +1,12 @@
--TEST--
Bug #73825 Heap out of bounds read on unserialize in finish_nested_data()
--FILE--
<?php
$obj = unserialize('O:8:"00000000":');
var_dump($obj);
?>
--EXPECTF--
Warning: Bad unserialize data in %sbug73825.php on line %d
Notice: unserialize(): Error at offset 13 of 15 bytes in %sbug73825.php on line %d
bool(false)
@@ -0,0 +1,10 @@
--TEST--
Bug #74111: Heap buffer overread (READ: 1) finish_nested_data from unserialize
--FILE--
<?php
$s = 'O:8:"stdClass":00000000';
var_dump(unserialize($s));
?>
--EXPECTF--
Notice: unserialize(): Error at offset 25 of 23 bytes in %s on line %d
bool(false)
@@ -0,0 +1,35 @@
--TEST--
Glob wrapper bypasses open_basedir
--INI--
open_basedir=/does_not_exist
--SKIPIF--
<?php
if (!in_array("glob", stream_get_wrappers())) echo "skip";
--FILE--
<?php
foreach ( [ __DIR__, "glob://".__DIR__ ] as $spec) {
echo "** Opening $spec\n";
$dir = opendir($spec);
if (!$dir) {
echo "Failed to open $spec\n";
continue;
}
if (false === readdir($dir)) {
echo "No files in $spec\n";
continue;
}
}
--EXPECTF--
** Opening %s
Warning: opendir(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (/does_not_exist) in %s%eglob-wrapper.php on line 5
Warning: opendir(%s): failed to open dir: Operation not permitted in %s%eglob-wrapper.php on line 5
Failed to open %s
** Opening glob://%s
Warning: opendir(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (/does_not_exist) in %s%eglob-wrapper.php on line 5
Warning: opendir(glob://%s): failed to open dir: operation failed in %s%eglob-wrapper.php on line 5
Failed to open glob://%s
+2 -2
View File
@@ -48,7 +48,7 @@ DONE
--EXPECTF--
Notice: unserialize(): Error at offset 0 of 3 bytes in %sbug70436.php on line %d
Notice: unserialize(): Error at offset 17 of 17 bytes in %sbug70436.php on line %d
Notice: unserialize(): Error at offset 16 of 17 bytes in %sbug70436.php on line %d
array(4) {
[0]=>
int(1)
@@ -62,4 +62,4 @@ array(4) {
[3]=>
bool(false)
}
DONE
DONE
+114 -68
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 0.13.7.5 */
/* Generated by re2c 0.15.3 */
#line 1 "ext/standard/var_unserializer.re"
/*
+----------------------------------------------------------------------+
@@ -28,6 +28,11 @@
#define VAR_ENTRIES_MAX 1024
#define VAR_ENTRIES_DBG 0
#define VAR_WAKEUP_FLAG 1
#define WITH_WAKEUP_FLAG(zv_ptr) ((zval *) ((zend_uintptr_t) zv_ptr | VAR_WAKEUP_FLAG))
#define WITHOUT_WAKEUP_FLAG(zv_ptr) ((zval *) ((zend_uintptr_t) zv_ptr & ~VAR_WAKEUP_FLAG))
#define HAS_WAKEUP_FLAG(zv_ptr) ((zend_uintptr_t) zv_ptr & VAR_WAKEUP_FLAG)
typedef struct {
zval *data[VAR_ENTRIES_MAX];
long used_slots;
@@ -58,12 +63,12 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
var_hash->data[var_hash->used_slots++] = *rval;
}
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
static inline zval **get_var_push_dtor_slot(php_unserialize_data_t *var_hashx)
{
var_entries *var_hash;
if (!var_hashx || !*var_hashx) {
return;
return NULL;
}
var_hash = (*var_hashx)->last_dtor;
@@ -85,8 +90,14 @@ PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
(*var_hashx)->last_dtor = var_hash;
}
return &var_hash->data[var_hash->used_slots++];
}
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
{
zval **slot = get_var_push_dtor_slot(var_hashx);
Z_ADDREF_PP(rval);
var_hash->data[var_hash->used_slots++] = *rval;
*slot = *rval;
}
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rval)
@@ -164,6 +175,9 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
void *next;
long i;
var_entries *var_hash = (*var_hashx)->first;
zend_bool wakeup_failed = 0;
TSRMLS_FETCH();
#if VAR_ENTRIES_DBG
fprintf(stderr, "var_destroy(%ld)\n", var_hash?var_hash->used_slots:-1L);
#endif
@@ -178,10 +192,35 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
while (var_hash) {
for (i = 0; i < var_hash->used_slots; i++) {
zval *zv = var_hash->data[i];
#if VAR_ENTRIES_DBG
fprintf(stderr, "var_destroy dtor(%p, %ld)\n", var_hash->data[i], Z_REFCOUNT_P(var_hash->data[i]));
#endif
zval_ptr_dtor(&var_hash->data[i]);
if (HAS_WAKEUP_FLAG(zv)) {
zv = WITHOUT_WAKEUP_FLAG(zv);
if (!wakeup_failed) {
zval *retval_ptr = NULL;
zval wakeup_name;
INIT_PZVAL(&wakeup_name);
ZVAL_STRINGL(&wakeup_name, "__wakeup", sizeof("__wakeup") - 1, 0);
BG(serialize_lock)++;
if (call_user_function_ex(CG(function_table), &zv, &wakeup_name, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC) == FAILURE || retval_ptr == NULL) {
wakeup_failed = 1;
zend_object_store_ctor_failed(zv TSRMLS_CC);
}
BG(serialize_lock)--;
if (retval_ptr) {
zval_ptr_dtor(&retval_ptr);
}
} else {
zend_object_store_ctor_failed(zv TSRMLS_CC);
}
}
zval_ptr_dtor(&zv);
}
next = var_hash->next;
efree(var_hash);
@@ -241,7 +280,7 @@ static char *unserialize_str(const unsigned char **p, size_t *len, size_t maxlen
#define YYMARKER marker
#line 249 "ext/standard/var_unserializer.re"
#line 288 "ext/standard/var_unserializer.re"
@@ -367,13 +406,12 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
static inline int finish_nested_data(UNSERIALIZE_PARAMETER)
{
if (*((*p)++) == '}')
return 1;
if (*p >= max || **p != '}') {
return 0;
}
#if SOMETHING_NEW_MIGHT_LEAD_TO_CRASH_ENABLE_IF_YOU_ARE_BRAVE
zval_ptr_dtor(rval);
#endif
return 0;
(*p)++;
return 1;
}
static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
@@ -405,6 +443,11 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
{
long elements;
if( *p >= max - 2) {
zend_error(E_WARNING, "Bad unserialize data");
return -1;
}
elements = parse_iv2((*p) + 2, p);
(*p) += 2;
@@ -415,7 +458,7 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
/* If this class implements Serializable, it should not land here but in object_custom(). The passed string
obviously doesn't descend from the regular serializer. */
zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ce->name);
return 0;
return -1;
}
return elements;
@@ -426,19 +469,16 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
#endif
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
{
zval *retval_ptr = NULL;
zval fname;
if (Z_TYPE_PP(rval) != IS_OBJECT) {
return 0;
}
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_PP(rval), elements, 1)) {
/* We've got partially constructed object on our hands here. Wipe it. */
if(Z_TYPE_PP(rval) == IS_OBJECT) {
zend_hash_clean(Z_OBJPROP_PP(rval));
zend_object_store_ctor_failed(*rval TSRMLS_CC);
}
/* We've got partially constructed object on our hands here. Wipe it. */
if (Z_TYPE_PP(rval) == IS_OBJECT) {
zend_hash_clean(Z_OBJPROP_PP(rval));
zend_object_store_ctor_failed(*rval TSRMLS_CC);
}
ZVAL_NULL(*rval);
return 0;
}
@@ -448,20 +488,16 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
}
if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY &&
zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))) {
INIT_PZVAL(&fname);
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0);
BG(serialize_lock)++;
call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC);
BG(serialize_lock)--;
}
if (retval_ptr) {
zval_ptr_dtor(&retval_ptr);
}
if (EG(exception)) {
return 0;
zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))
) {
/* Store object for delayed __wakeup call. Remove references. */
zval **slot = get_var_push_dtor_slot(var_hash);
zval *zv = *rval;
Z_ADDREF_P(zv);
if (PZVAL_IS_REF(zv)) {
SEPARATE_ZVAL(&zv);
}
*slot = WITH_WAKEUP_FLAG(zv);
}
return finish_nested_data(UNSERIALIZE_PASSTHRU);
@@ -492,7 +528,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
#line 496 "ext/standard/var_unserializer.c"
#line 532 "ext/standard/var_unserializer.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -529,7 +565,6 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
yych = *YYCURSOR;
switch (yych) {
@@ -552,9 +587,9 @@ yy2:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ':') goto yy95;
yy3:
#line 861 "ext/standard/var_unserializer.re"
#line 908 "ext/standard/var_unserializer.re"
{ return 0; }
#line 558 "ext/standard/var_unserializer.c"
#line 593 "ext/standard/var_unserializer.c"
yy4:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ':') goto yy89;
@@ -597,13 +632,13 @@ yy13:
goto yy3;
yy14:
++YYCURSOR;
#line 855 "ext/standard/var_unserializer.re"
#line 902 "ext/standard/var_unserializer.re"
{
/* this is the case where we have less data than planned */
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data");
return 0; /* not sure if it should be 0 or 1 here? */
}
#line 607 "ext/standard/var_unserializer.c"
#line 642 "ext/standard/var_unserializer.c"
yy16:
yych = *++YYCURSOR;
goto yy3;
@@ -634,7 +669,7 @@ yy20:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 708 "ext/standard/var_unserializer.re"
#line 748 "ext/standard/var_unserializer.re"
{
size_t len, len2, len3, maxlen;
long elements;
@@ -745,6 +780,7 @@ yy20:
}
/* The callback function may have defined the class */
BG(serialize_lock)++;
if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) {
ce = *pce;
} else {
@@ -752,6 +788,7 @@ yy20:
incomplete_class = 1;
ce = PHP_IC_ENTRY;
}
BG(serialize_lock)--;
zval_ptr_dtor(&user_func);
zval_ptr_dtor(&arg_func_name);
@@ -774,6 +811,11 @@ yy20:
elements = object_common1(UNSERIALIZE_PASSTHRU, ce);
if (elements < 0) {
efree(class_name);
return 0;
}
if (incomplete_class) {
php_store_class_name(*rval, class_name, len2);
}
@@ -781,7 +823,7 @@ yy20:
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
#line 785 "ext/standard/var_unserializer.c"
#line 827 "ext/standard/var_unserializer.c"
yy25:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -806,16 +848,20 @@ yy27:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 699 "ext/standard/var_unserializer.re"
#line 735 "ext/standard/var_unserializer.re"
{
long elements;
if (!var_hash) return 0;
INIT_PZVAL(*rval);
return object_common2(UNSERIALIZE_PASSTHRU,
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
elements = object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR);
if (elements < 0) {
return 0;
}
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
#line 819 "ext/standard/var_unserializer.c"
#line 865 "ext/standard/var_unserializer.c"
yy32:
yych = *++YYCURSOR;
if (yych == '+') goto yy33;
@@ -836,7 +882,7 @@ yy34:
yych = *++YYCURSOR;
if (yych != '{') goto yy18;
++YYCURSOR;
#line 678 "ext/standard/var_unserializer.re"
#line 714 "ext/standard/var_unserializer.re"
{
long elements = parse_iv(start + 2);
/* use iv() not uiv() in order to check data range */
@@ -857,7 +903,7 @@ yy34:
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
#line 861 "ext/standard/var_unserializer.c"
#line 907 "ext/standard/var_unserializer.c"
yy39:
yych = *++YYCURSOR;
if (yych == '+') goto yy40;
@@ -878,7 +924,7 @@ yy41:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 643 "ext/standard/var_unserializer.re"
#line 679 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
char *str;
@@ -913,7 +959,7 @@ yy41:
ZVAL_STRINGL(*rval, str, len, 0);
return 1;
}
#line 917 "ext/standard/var_unserializer.c"
#line 963 "ext/standard/var_unserializer.c"
yy46:
yych = *++YYCURSOR;
if (yych == '+') goto yy47;
@@ -934,7 +980,7 @@ yy48:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
#line 610 "ext/standard/var_unserializer.re"
#line 646 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
char *str;
@@ -967,7 +1013,7 @@ yy48:
ZVAL_STRINGL(*rval, str, len, 1);
return 1;
}
#line 971 "ext/standard/var_unserializer.c"
#line 1017 "ext/standard/var_unserializer.c"
yy53:
yych = *++YYCURSOR;
if (yych <= '/') {
@@ -1055,7 +1101,7 @@ yy61:
}
yy63:
++YYCURSOR;
#line 600 "ext/standard/var_unserializer.re"
#line 636 "ext/standard/var_unserializer.re"
{
#if SIZEOF_LONG == 4
use_double:
@@ -1065,7 +1111,7 @@ use_double:
ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL));
return 1;
}
#line 1069 "ext/standard/var_unserializer.c"
#line 1115 "ext/standard/var_unserializer.c"
yy65:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1124,7 +1170,7 @@ yy73:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 585 "ext/standard/var_unserializer.re"
#line 621 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
@@ -1139,7 +1185,7 @@ yy73:
return 1;
}
#line 1143 "ext/standard/var_unserializer.c"
#line 1189 "ext/standard/var_unserializer.c"
yy76:
yych = *++YYCURSOR;
if (yych == 'N') goto yy73;
@@ -1166,7 +1212,7 @@ yy79:
if (yych <= '9') goto yy79;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 558 "ext/standard/var_unserializer.re"
#line 594 "ext/standard/var_unserializer.re"
{
#if SIZEOF_LONG == 4
int digits = YYCURSOR - start - 3;
@@ -1193,7 +1239,7 @@ yy79:
ZVAL_LONG(*rval, parse_iv(start + 2));
return 1;
}
#line 1197 "ext/standard/var_unserializer.c"
#line 1243 "ext/standard/var_unserializer.c"
yy83:
yych = *++YYCURSOR;
if (yych <= '/') goto yy18;
@@ -1201,24 +1247,24 @@ yy83:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 551 "ext/standard/var_unserializer.re"
#line 587 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_BOOL(*rval, parse_iv(start + 2));
return 1;
}
#line 1212 "ext/standard/var_unserializer.c"
#line 1258 "ext/standard/var_unserializer.c"
yy87:
++YYCURSOR;
#line 544 "ext/standard/var_unserializer.re"
#line 580 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
INIT_PZVAL(*rval);
ZVAL_NULL(*rval);
return 1;
}
#line 1222 "ext/standard/var_unserializer.c"
#line 1268 "ext/standard/var_unserializer.c"
yy89:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1241,7 +1287,7 @@ yy91:
if (yych <= '9') goto yy91;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 521 "ext/standard/var_unserializer.re"
#line 557 "ext/standard/var_unserializer.re"
{
long id;
@@ -1264,7 +1310,7 @@ yy91:
return 1;
}
#line 1268 "ext/standard/var_unserializer.c"
#line 1314 "ext/standard/var_unserializer.c"
yy95:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1287,7 +1333,7 @@ yy97:
if (yych <= '9') goto yy97;
if (yych != ';') goto yy18;
++YYCURSOR;
#line 500 "ext/standard/var_unserializer.re"
#line 536 "ext/standard/var_unserializer.re"
{
long id;
@@ -1308,9 +1354,9 @@ yy97:
return 1;
}
#line 1312 "ext/standard/var_unserializer.c"
#line 1358 "ext/standard/var_unserializer.c"
}
#line 863 "ext/standard/var_unserializer.re"
#line 910 "ext/standard/var_unserializer.re"
return 0;
+82 -35
View File
@@ -26,6 +26,11 @@
#define VAR_ENTRIES_MAX 1024
#define VAR_ENTRIES_DBG 0
#define VAR_WAKEUP_FLAG 1
#define WITH_WAKEUP_FLAG(zv_ptr) ((zval *) ((zend_uintptr_t) zv_ptr | VAR_WAKEUP_FLAG))
#define WITHOUT_WAKEUP_FLAG(zv_ptr) ((zval *) ((zend_uintptr_t) zv_ptr & ~VAR_WAKEUP_FLAG))
#define HAS_WAKEUP_FLAG(zv_ptr) ((zend_uintptr_t) zv_ptr & VAR_WAKEUP_FLAG)
typedef struct {
zval *data[VAR_ENTRIES_MAX];
long used_slots;
@@ -56,12 +61,12 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
var_hash->data[var_hash->used_slots++] = *rval;
}
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
static inline zval **get_var_push_dtor_slot(php_unserialize_data_t *var_hashx)
{
var_entries *var_hash;
if (!var_hashx || !*var_hashx) {
return;
return NULL;
}
var_hash = (*var_hashx)->last_dtor;
@@ -83,8 +88,14 @@ PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
(*var_hashx)->last_dtor = var_hash;
}
return &var_hash->data[var_hash->used_slots++];
}
PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
{
zval **slot = get_var_push_dtor_slot(var_hashx);
Z_ADDREF_PP(rval);
var_hash->data[var_hash->used_slots++] = *rval;
*slot = *rval;
}
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rval)
@@ -162,6 +173,9 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
void *next;
long i;
var_entries *var_hash = (*var_hashx)->first;
zend_bool wakeup_failed = 0;
TSRMLS_FETCH();
#if VAR_ENTRIES_DBG
fprintf(stderr, "var_destroy(%ld)\n", var_hash?var_hash->used_slots:-1L);
#endif
@@ -176,10 +190,35 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
while (var_hash) {
for (i = 0; i < var_hash->used_slots; i++) {
zval *zv = var_hash->data[i];
#if VAR_ENTRIES_DBG
fprintf(stderr, "var_destroy dtor(%p, %ld)\n", var_hash->data[i], Z_REFCOUNT_P(var_hash->data[i]));
#endif
zval_ptr_dtor(&var_hash->data[i]);
if (HAS_WAKEUP_FLAG(zv)) {
zv = WITHOUT_WAKEUP_FLAG(zv);
if (!wakeup_failed) {
zval *retval_ptr = NULL;
zval wakeup_name;
INIT_PZVAL(&wakeup_name);
ZVAL_STRINGL(&wakeup_name, "__wakeup", sizeof("__wakeup") - 1, 0);
BG(serialize_lock)++;
if (call_user_function_ex(CG(function_table), &zv, &wakeup_name, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC) == FAILURE || retval_ptr == NULL) {
wakeup_failed = 1;
zend_object_store_ctor_failed(zv TSRMLS_CC);
}
BG(serialize_lock)--;
if (retval_ptr) {
zval_ptr_dtor(&retval_ptr);
}
} else {
zend_object_store_ctor_failed(zv TSRMLS_CC);
}
}
zval_ptr_dtor(&zv);
}
next = var_hash->next;
efree(var_hash);
@@ -371,13 +410,12 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long
static inline int finish_nested_data(UNSERIALIZE_PARAMETER)
{
if (*((*p)++) == '}')
return 1;
if (*p >= max || **p != '}') {
return 0;
}
#if SOMETHING_NEW_MIGHT_LEAD_TO_CRASH_ENABLE_IF_YOU_ARE_BRAVE
zval_ptr_dtor(rval);
#endif
return 0;
(*p)++;
return 1;
}
static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
@@ -409,6 +447,11 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
{
long elements;
if( *p >= max - 2) {
zend_error(E_WARNING, "Bad unserialize data");
return -1;
}
elements = parse_iv2((*p) + 2, p);
(*p) += 2;
@@ -419,7 +462,7 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
/* If this class implements Serializable, it should not land here but in object_custom(). The passed string
obviously doesn't descend from the regular serializer. */
zend_error(E_WARNING, "Erroneous data format for unserializing '%s'", ce->name);
return 0;
return -1;
}
return elements;
@@ -430,19 +473,16 @@ static inline long object_common1(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
#endif
static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
{
zval *retval_ptr = NULL;
zval fname;
if (Z_TYPE_PP(rval) != IS_OBJECT) {
return 0;
}
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_OBJPROP_PP(rval), elements, 1)) {
/* We've got partially constructed object on our hands here. Wipe it. */
if(Z_TYPE_PP(rval) == IS_OBJECT) {
zend_hash_clean(Z_OBJPROP_PP(rval));
zend_object_store_ctor_failed(*rval TSRMLS_CC);
}
/* We've got partially constructed object on our hands here. Wipe it. */
if (Z_TYPE_PP(rval) == IS_OBJECT) {
zend_hash_clean(Z_OBJPROP_PP(rval));
zend_object_store_ctor_failed(*rval TSRMLS_CC);
}
ZVAL_NULL(*rval);
return 0;
}
@@ -452,20 +492,16 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, long elements)
}
if (Z_OBJCE_PP(rval) != PHP_IC_ENTRY &&
zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))) {
INIT_PZVAL(&fname);
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1, 0);
BG(serialize_lock)++;
call_user_function_ex(CG(function_table), rval, &fname, &retval_ptr, 0, 0, 1, NULL TSRMLS_CC);
BG(serialize_lock)--;
}
if (retval_ptr) {
zval_ptr_dtor(&retval_ptr);
}
if (EG(exception)) {
return 0;
zend_hash_exists(&Z_OBJCE_PP(rval)->function_table, "__wakeup", sizeof("__wakeup"))
) {
/* Store object for delayed __wakeup call. Remove references. */
zval **slot = get_var_push_dtor_slot(var_hash);
zval *zv = *rval;
Z_ADDREF_P(zv);
if (PZVAL_IS_REF(zv)) {
SEPARATE_ZVAL(&zv);
}
*slot = WITH_WAKEUP_FLAG(zv);
}
return finish_nested_data(UNSERIALIZE_PASSTHRU);
@@ -697,12 +733,16 @@ use_double:
}
"o:" iv ":" ["] {
long elements;
if (!var_hash) return 0;
INIT_PZVAL(*rval);
return object_common2(UNSERIALIZE_PASSTHRU,
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
elements = object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR);
if (elements < 0) {
return 0;
}
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
object ":" uiv ":" ["] {
@@ -815,6 +855,7 @@ object ":" uiv ":" ["] {
}
/* The callback function may have defined the class */
BG(serialize_lock)++;
if (zend_lookup_class(class_name, len2, &pce TSRMLS_CC) == SUCCESS) {
ce = *pce;
} else {
@@ -822,6 +863,7 @@ object ":" uiv ":" ["] {
incomplete_class = 1;
ce = PHP_IC_ENTRY;
}
BG(serialize_lock)--;
zval_ptr_dtor(&user_func);
zval_ptr_dtor(&arg_func_name);
@@ -844,6 +886,11 @@ object ":" uiv ":" ["] {
elements = object_common1(UNSERIALIZE_PASSTHRU, ce);
if (elements < 0) {
efree(class_name);
return 0;
}
if (incomplete_class) {
php_store_class_name(*rval, class_name, len2);
}
+18
View File
@@ -0,0 +1,18 @@
--TEST--
Bug #73631 (Memory leak due to invalid wddx stack processing)
--SKIPIF--
<?php if (!extension_loaded("wddx")) print "skip"; ?>
--FILE--
<?php
$xml = <<<EOF
<?xml version="1.0" ?>
<wddxPacket version="1.0">
<number>1234</number>
<binary><boolean/></binary>
</wddxPacket>
EOF;
$wddx = wddx_deserialize($xml);
var_dump($wddx);
?>
--EXPECTF--
int(1234)
+16
View File
@@ -0,0 +1,16 @@
--TEST--
Bug #74145 (wddx parsing empty boolean tag leads to SIGSEGV)
--SKIPIF--
<?php
if (!extension_loaded("wddx")) print "skip";
?>
--FILE--
<?php
$data = file_get_contents(__DIR__ . '/bug74145.xml');
$wddx = wddx_deserialize($data);
var_dump($wddx);
?>
DONE
--EXPECTF--
NULL
DONE
+9
View File
@@ -0,0 +1,9 @@
<?xml version='1.0' ?>
<!DOCTYPE et SYSTEM 'w'>
<wddxPacket ven='1.0'>
<array>
<var Name="name">
<boolean ></boolean>
</var>
</array>
</wddxPacket>
+20
View File
@@ -0,0 +1,20 @@
--TEST--
Bug #75055 Out-Of-Bounds Read in timelib_meridian()
--SKIPIF--
<?php if (!extension_loaded("wddx")) print "skip"; ?>
--FILE--
<?php
$file_str = dirname(__FILE__) . "/bug75055.wddx";
$wddx_str = file_get_contents($file_str);
print strlen($wddx_str) . " bytes read.\n";
var_dump(wddx_deserialize($wddx_str));
?>
--EXPECT--
323 bytes read.
array(1) {
["aDateTime"]=>
string(12) "frONt of 0 0"
}
+13
View File
@@ -0,0 +1,13 @@
<?xml version='1.0'?>
<!DOCTYPE wddxPacket SYSTEM 'wddx_0100.dtd'>
<wddxPacket version='1.0'>
<header/>
<data>
<struct>
<var name='aDateTime'>
<dateTime>frONt of 0 0</dateTime>
</var>
</struct>
</data>
</wddxPacket>
+12 -3
View File
@@ -801,16 +801,23 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
if (atts) for (i = 0; atts[i]; i++) {
if (!strcmp(atts[i], EL_VALUE) && atts[i+1] && atts[i+1][0]) {
ent.type = ST_BOOLEAN;
SET_STACK_VARNAME;
ALLOC_ZVAL(ent.data);
INIT_PZVAL(ent.data);
Z_TYPE_P(ent.data) = IS_BOOL;
ent.type = ST_BOOLEAN;
SET_STACK_VARNAME;
wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
php_wddx_process_data(user_data, atts[i+1], strlen(atts[i+1]));
break;
}
} else {
ALLOC_ZVAL(ent.data);
INIT_PZVAL(ent.data);
Z_TYPE_P(ent.data) = IS_BOOL;
ent.type = ST_BOOLEAN;
SET_STACK_VARNAME;
ZVAL_FALSE(ent.data);
wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
}
} else if (!strcmp(name, EL_NULL)) {
ent.type = ST_NULL;
@@ -1052,6 +1059,8 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
} else {
zend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL);
}
} else if (!strcmp(name, EL_BINARY) && Z_STRLEN_P(ent1->data) < 1) {
zval_ptr_dtor(&ent1->data);
}
efree(ent1);
} else {
+6 -1
View File
@@ -726,7 +726,12 @@ _zip_read_eocd64(FILE *f, const zip_uint8_t *eocd64loc, const zip_uint8_t *buf,
_zip_error_set(error, ZIP_ER_SEEK, EFBIG);
return NULL;
}
if ((flags & ZIP_CHECKCONS) && offset+size != eocd_offset) {
if (offset+size > buf_offset + eocd_offset) {
/* cdir spans past EOCD record */
_zip_error_set(error, ZIP_ER_INCONS, 0);
return NULL;
}
if ((flags & ZIP_CHECKCONS) && offset+size != buf_offset + eocd_offset) {
_zip_error_set(error, ZIP_ER_INCONS, 0);
return NULL;
}
+1 -1
View File
@@ -2662,7 +2662,7 @@ static ZIPARCHIVE_METHOD(extractTo)
RETURN_FALSE;
}
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &pathto, &pathto_len, &zval_files) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|z", &pathto, &pathto_len, &zval_files) == FAILURE) {
return;
}
+9 -3
View File
@@ -237,11 +237,14 @@ typedef struct post_var_data {
char *ptr;
char *end;
uint64_t cnt;
/* Bytes in ptr that have already been scanned for '&' */
size_t already_scanned;
} post_var_data_t;
static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSRMLS_DC)
{
char *ksep, *vsep, *val;
char *start, *ksep, *vsep, *val;
size_t klen, vlen;
/* FIXME: string-size_t */
unsigned int new_vlen;
@@ -250,9 +253,11 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSR
return 0;
}
vsep = memchr(var->ptr, '&', var->end - var->ptr);
start = var->ptr + var->already_scanned;
vsep = memchr(start, '&', var->end - start);
if (!vsep) {
if (!eof) {
var->already_scanned = var->end - var->ptr;
return 0;
} else {
vsep = var->end;
@@ -285,6 +290,7 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof TSR
efree(val);
var->ptr = vsep + (vsep != var->end);
var->already_scanned = 0;
return 1;
}
@@ -304,7 +310,7 @@ static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_bool eof
}
}
if (!eof) {
if (!eof && vars->str.c != vars->ptr) {
memmove(vars->str.c, vars->ptr, vars->str.len = vars->end - vars->ptr);
}
return SUCCESS;
+4 -4
View File
@@ -2,7 +2,7 @@
/* edit configure.in to change version number */
#define PHP_MAJOR_VERSION 5
#define PHP_MINOR_VERSION 6
#define PHP_RELEASE_VERSION 30
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "5.6.30-dev"
#define PHP_VERSION_ID 50630
#define PHP_RELEASE_VERSION 35
#define PHP_EXTRA_VERSION ""
#define PHP_VERSION "5.6.35"
#define PHP_VERSION_ID 50635
+4 -4
View File
@@ -213,10 +213,6 @@ static php_stream *php_glob_stream_opener(php_stream_wrapper *wrapper, const cha
int ret;
const char *tmp, *pos;
if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(path TSRMLS_CC)) {
return NULL;
}
if (!strncmp(path, "glob://", sizeof("glob://")-1)) {
path += sizeof("glob://")-1;
if (opened_path) {
@@ -224,6 +220,10 @@ static php_stream *php_glob_stream_opener(php_stream_wrapper *wrapper, const cha
}
}
if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(path TSRMLS_CC)) {
return NULL;
}
pglob = ecalloc(sizeof(*pglob), 1);
if (0 != (ret = glob(path, pglob->flags & GLOB_FLAGMASK, NULL, &pglob->glob))) {
+3
View File
@@ -132,6 +132,7 @@ static struct ini_value_parser_s ini_fpm_pool_options[] = {
{ "listen.mode", &fpm_conf_set_string, WPO(listen_mode) },
{ "listen.allowed_clients", &fpm_conf_set_string, WPO(listen_allowed_clients) },
{ "process.priority", &fpm_conf_set_integer, WPO(process_priority) },
{ "process.dumpable", &fpm_conf_set_boolean, WPO(process_dumpable) },
{ "pm", &fpm_conf_set_pm, WPO(pm) },
{ "pm.max_children", &fpm_conf_set_integer, WPO(pm_max_children) },
{ "pm.start_servers", &fpm_conf_set_integer, WPO(pm_start_servers) },
@@ -613,6 +614,7 @@ static void *fpm_worker_pool_config_alloc() /* {{{ */
wp->config->listen_backlog = FPM_BACKLOG_DEFAULT;
wp->config->pm_process_idle_timeout = 10; /* 10s by default */
wp->config->process_priority = 64; /* 64 means unset */
wp->config->process_dumpable = 0;
wp->config->clear_env = 1;
if (!fpm_worker_all_pools) {
@@ -1602,6 +1604,7 @@ static void fpm_conf_dump() /* {{{ */
} else {
zlog(ZLOG_NOTICE, "\tprocess.priority = %d", wp->config->process_priority);
}
zlog(ZLOG_NOTICE, "\tprocess.dumpable = %s", BOOL2STR(wp->config->process_dumpable));
zlog(ZLOG_NOTICE, "\tpm = %s", PM2STR(wp->config->pm));
zlog(ZLOG_NOTICE, "\tpm.max_children = %d", wp->config->pm_max_children);
zlog(ZLOG_NOTICE, "\tpm.start_servers = %d", wp->config->pm_start_servers);
+1
View File
@@ -64,6 +64,7 @@ struct fpm_worker_pool_config_s {
char *listen_mode;
char *listen_allowed_clients;
int process_priority;
int process_dumpable;
int pm;
int pm_max_children;
int pm_start_servers;
+1 -1
View File
@@ -398,7 +398,7 @@ int fpm_unix_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
}
#ifdef HAVE_PRCTL
if (0 > prctl(PR_SET_DUMPABLE, 1, 0, 0, 0)) {
if (wp->config->process_dumpable && 0 > prctl(PR_SET_DUMPABLE, 1, 0, 0, 0)) {
zlog(ZLOG_SYSERROR, "[pool %s] failed to prctl(PR_SET_DUMPABLE)", wp->config->name);
}
#endif
+6
View File
@@ -197,6 +197,12 @@ listen = 127.0.0.1:9000
; Default Value: no set
; process.priority = -19
; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
; or group is differrent than the master process user. It allows to create process
; core dump and ptrace the process for the pool user.
; Default Value: no
; process.dumpable = yes
; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
+4 -1
View File
@@ -1,7 +1,10 @@
--TEST--
FPM: Test IPv6 support
--SKIPIF--
<?php include "skipif.inc"; ?>
<?php include "skipif.inc";
@stream_socket_client('tcp://[::1]:0', $errno);
if ($errno != 111) die('skip IPv6 not supported.');
?>
--FILE--
<?php
Loaded 100 of 105 files, more files were not shown because too many files have changed in this diff. Show more