mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-11 11:10:49 +00:00
Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da12ca9c1e | ||
|
|
d6f62b7d6e | ||
|
|
bd38aea92c | ||
|
|
40f48594d2 | ||
|
|
20ce2fe8e3 | ||
|
|
8d7766a948 | ||
|
|
758a0cd8b3 | ||
|
|
d3221181c3 | ||
|
|
686f4e01e6 | ||
|
|
d9fac3953d | ||
|
|
749cae0fa1 | ||
|
|
b0d8f96048 | ||
|
|
3493ed5b52 | ||
|
|
72d03f8aa4 | ||
|
|
bab470f6ba | ||
|
|
b2d89c93e8 | ||
|
|
4dd455c6d2 | ||
|
|
52f58eeaec | ||
|
|
a20112a1d6 | ||
|
|
5ba1cbec07 | ||
|
|
326ac100ac | ||
|
|
19c10bb629 | ||
|
|
0a85fd9877 | ||
|
|
9a5dff415a | ||
|
|
bd6983bb1e | ||
|
|
8889b13853 | ||
|
|
e0e2323e7d | ||
|
|
91641c23fc | ||
|
|
e8f76d10ab | ||
|
|
be6b7e5eeb |
No files matched your search
@@ -1,6 +1,6 @@
|
||||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? 2016 PHP 7.0.10
|
||||
18 Aug 2016 PHP 7.0.10
|
||||
|
||||
- Core:
|
||||
. Fixed bug #72629 (Caught exception assignment to variables ignores
|
||||
@@ -22,7 +22,16 @@ PHP NEWS
|
||||
(Yuji Uchiyama)
|
||||
. Fixed potential segfault in object storage freeing in shutdown sequence.
|
||||
(Bob)
|
||||
. Fixed bug #72663 (Create an Unexpected Object and Don't Invoke
|
||||
__wakeup() in Deserialization). (Stas)
|
||||
. Fixed bug #72681 (PHP Session Data Injection Vulnerability). (Stas)
|
||||
. Fixed bug #72683 (getmxrr broken). (Anatol)
|
||||
. Fixed bug #72742 (memory allocator fails to realloc small block to large
|
||||
one). (Stas)
|
||||
|
||||
- Bz2:
|
||||
. Fixed bug #72837 (integer overflow in bzdecompress caused heap
|
||||
corruption). (Stas)
|
||||
|
||||
- Calendar:
|
||||
. Fixed bug #67976 (cal_days_month() fails for final month of the French
|
||||
@@ -37,10 +46,15 @@ PHP NEWS
|
||||
. Fixed bug #71709 (curl_setopt segfault with empty CURLOPT_HTTPHEADER).
|
||||
(Pierrick)
|
||||
. Fixed bug #71929 (CURLINFO_CERTINFO data parsing error). (Pierrick)
|
||||
. Fixed bug #72674 (Heap overflow in curl_escape). (Stas)
|
||||
|
||||
- DOM:
|
||||
. Fixed bug #66502 (DOM document dangling reference). (Sean Heelan, cmb)
|
||||
|
||||
- EXIF:
|
||||
. Fixed bug #72735 (Samsung picture thumb not read (zero size)). (Kalle, Remi)
|
||||
. Fixed bug #72627 (Memory Leakage In exif_process_IFD_in_TIFF). (Stas)
|
||||
|
||||
- Filter:
|
||||
. Fixed bug #71745 (FILTER_FLAG_NO_RES_RANGE does not cover whole 127.0.0.0/8
|
||||
range). (bugs dot php dot net at majkl578 dot cz)
|
||||
@@ -57,6 +71,8 @@ PHP NEWS
|
||||
blendingmode). (cmb)
|
||||
. Fixed bug #66555 (Always false condition in ext/gd/libgd/gdkanji.c). (cmb)
|
||||
. Fixed bug #68712 (suspicious if-else statements). (cmb)
|
||||
. Fixed bug #72697 (select_colors write out-of-bounds). (Stas)
|
||||
. Fixed bug #72730 (imagegammacorrect allows arbitrary write access). (Stas)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug #72639 (Segfault when instantiating class that extends
|
||||
@@ -74,6 +90,9 @@ PHP NEWS
|
||||
. Fixed bug #72710 (`mb_ereg` causes buffer overflow on regexp compile error).
|
||||
(ju1ius)
|
||||
|
||||
- Mcrypt:
|
||||
. Fixed bug #72782 (Heap Overflow due to integer overflows). (Stas)
|
||||
|
||||
- Opcache:
|
||||
. Fixed bug #72590 (Opcache restart with kill_all_lockers does not work).
|
||||
(Keyur)
|
||||
@@ -83,8 +102,6 @@ PHP NEWS
|
||||
|
||||
- PDO_pgsql:
|
||||
. Fixed bug #70313 (PDO statement fails to throw exception). (Matteo)
|
||||
. Implemented FR #72633 (Postgres PDO lastInsertId() should work without
|
||||
specifying a sequence). (Pablo Santiago Sánchez)
|
||||
|
||||
- Reflection:
|
||||
. Fixed bug #72222 (ReflectionClass::export doesn't handle array constants).
|
||||
@@ -94,6 +111,10 @@ PHP NEWS
|
||||
. Fixed bug #72588 (Using global var doesn't work while accessing SimpleXML
|
||||
element). (Laruence)
|
||||
|
||||
- SNMP:
|
||||
. Fixed bug #72708 (php_snmp_parse_oid integer overflow in memory
|
||||
allocation). (djodjo at gmail dot com)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #55701 (GlobIterator throws LogicException). (Valentin VĂLCIU)
|
||||
. Fixed bug #72646 (SplFileObject::getCsvControl does not return the escape
|
||||
@@ -125,6 +146,8 @@ PHP NEWS
|
||||
. Fixed bug #54431 (opendir() does not work with ftps:// wrapper). (vhuk)
|
||||
. Fixed bug #72667 (opendir() with ftp:// attempts to open data stream for
|
||||
non-existent directories). (vhuk)
|
||||
. Fixed bug #72771 (ftps:// wrapper is vulnerable to protocol downgrade
|
||||
attack). (Stas)
|
||||
|
||||
- XMLRPC:
|
||||
. Fixed bug #72647 (xmlrpc_encode() unexpected output after referencing
|
||||
@@ -134,7 +157,12 @@ PHP NEWS
|
||||
. Fixed bug #72564 (boolean always deserialized as "true") (Remi)
|
||||
. Fixed bug #72142 (WDDX Packet Injection Vulnerability in
|
||||
wddx_serialize_value()). (Taoguang Chen)
|
||||
|
||||
. Fixed bug #72749 (wddx_deserialize allows illegal memory access) (Stas)
|
||||
. Fixed bug #72750 (wddx_deserialize null dereference). (Stas)
|
||||
. Fixed bug #72790 (wddx_deserialize null dereference with invalid xml).
|
||||
(Stas)
|
||||
. Fixed bug #72799 (wddx_deserialize null dereference in
|
||||
php_wddx_pop_element). (Stas)
|
||||
|
||||
- Zip:
|
||||
. Fixed bug #72660 (NULL Pointer dereference in zend_virtual_cwd).
|
||||
|
||||
+12
-12
@@ -1548,21 +1548,21 @@ static void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, si
|
||||
|
||||
ZEND_MM_CHECK(chunk->heap == heap, "zend_mm_heap corrupted");
|
||||
if (info & ZEND_MM_IS_SRUN) {
|
||||
int old_bin_num, bin_num;
|
||||
|
||||
old_bin_num = ZEND_MM_SRUN_BIN_NUM(info);
|
||||
int old_bin_num = ZEND_MM_SRUN_BIN_NUM(info);
|
||||
old_size = bin_data_size[old_bin_num];
|
||||
bin_num = ZEND_MM_SMALL_SIZE_TO_BIN(size);
|
||||
if (old_bin_num == bin_num) {
|
||||
if (size <= ZEND_MM_MAX_SMALL_SIZE) {
|
||||
int bin_num = ZEND_MM_SMALL_SIZE_TO_BIN(size);
|
||||
if (old_bin_num == bin_num) {
|
||||
#if ZEND_DEBUG
|
||||
dbg = zend_mm_get_debug_info(heap, ptr);
|
||||
dbg->size = real_size;
|
||||
dbg->filename = __zend_filename;
|
||||
dbg->orig_filename = __zend_orig_filename;
|
||||
dbg->lineno = __zend_lineno;
|
||||
dbg->orig_lineno = __zend_orig_lineno;
|
||||
dbg = zend_mm_get_debug_info(heap, ptr);
|
||||
dbg->size = real_size;
|
||||
dbg->filename = __zend_filename;
|
||||
dbg->orig_filename = __zend_orig_filename;
|
||||
dbg->lineno = __zend_lineno;
|
||||
dbg->orig_lineno = __zend_orig_lineno;
|
||||
#endif
|
||||
return ptr;
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
} else /* if (info & ZEND_MM_IS_LARGE_RUN) */ {
|
||||
ZEND_MM_CHECK(ZEND_MM_ALIGNED_OFFSET(page_offset, ZEND_MM_PAGE_SIZE) == 0, "zend_mm_heap corrupted");
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||
PHP_MAJOR_VERSION=7
|
||||
PHP_MINOR_VERSION=0
|
||||
PHP_RELEASE_VERSION=10
|
||||
PHP_EXTRA_VERSION="-dev"
|
||||
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`
|
||||
|
||||
|
||||
+14
-4
@@ -594,16 +594,26 @@ static PHP_FUNCTION(bzdecompress)
|
||||
/* compression is better then 2:1, need to allocate more memory */
|
||||
bzs.avail_out = source_len;
|
||||
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
|
||||
if (size > SIZE_MAX) {
|
||||
/* no reason to continue if we're going to drop it anyway */
|
||||
break;
|
||||
}
|
||||
dest = safe_erealloc(dest, 1, bzs.avail_out+1, (size_t) size );
|
||||
bzs.next_out = dest + size;
|
||||
}
|
||||
|
||||
if (error == BZ_STREAM_END || error == BZ_OK) {
|
||||
size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32;
|
||||
dest = safe_erealloc(dest, 1, (size_t) size, 1);
|
||||
dest[size] = '\0';
|
||||
RETVAL_STRINGL(dest, (int) size);
|
||||
efree(dest);
|
||||
if (size > SIZE_MAX) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Decompressed size too big, max is %zd", SIZE_MAX);
|
||||
efree(dest);
|
||||
RETVAL_LONG(BZ_MEM_ERROR);
|
||||
} else {
|
||||
dest = safe_erealloc(dest, 1, (size_t) size, 1);
|
||||
dest[size] = '\0';
|
||||
RETVAL_STRINGL(dest, (size_t) size);
|
||||
efree(dest);
|
||||
}
|
||||
} else { /* real error */
|
||||
efree(dest);
|
||||
RETVAL_LONG(error);
|
||||
|
||||
@@ -3517,7 +3517,7 @@ PHP_FUNCTION(curl_reset)
|
||||
PHP_FUNCTION(curl_escape)
|
||||
{
|
||||
char *str = NULL, *res = NULL;
|
||||
size_t str_len = 0;
|
||||
size_t str_len = 0;
|
||||
zval *zid;
|
||||
php_curl *ch;
|
||||
|
||||
@@ -3529,6 +3529,10 @@ PHP_FUNCTION(curl_escape)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ZEND_SIZE_T_INT_OVFL(str_len)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((res = curl_easy_escape(ch->cp, str, str_len))) {
|
||||
RETVAL_STRING(res);
|
||||
curl_free(res);
|
||||
@@ -3556,7 +3560,7 @@ PHP_FUNCTION(curl_unescape)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (str_len > INT_MAX) {
|
||||
if (ZEND_SIZE_T_INT_OVFL(str_len)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
+16
-2
@@ -1703,6 +1703,10 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c
|
||||
break;
|
||||
case TAG_FMT_UNDEFINED:
|
||||
if (value) {
|
||||
if (tag == TAG_MAKER_NOTE) {
|
||||
length = MIN(length, strlen(value));
|
||||
}
|
||||
|
||||
/* do not recompute length here */
|
||||
info_value->s = estrndup(value, length);
|
||||
info_data->length = length;
|
||||
@@ -2712,8 +2716,14 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
|
||||
char *dir_start;
|
||||
|
||||
for (i=0; i<=sizeof(maker_note_array)/sizeof(maker_note_type); i++) {
|
||||
if (i==sizeof(maker_note_array)/sizeof(maker_note_type))
|
||||
return FALSE;
|
||||
if (i==sizeof(maker_note_array)/sizeof(maker_note_type)) {
|
||||
#ifdef EXIF_DEBUG
|
||||
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "No maker note data found. Detected maker: %s (length = %d)", ImageInfo->make, strlen(ImageInfo->make));
|
||||
#endif
|
||||
/* unknown manufacturer, not an error, use it as a string */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
maker_note = maker_note_array+i;
|
||||
|
||||
/*exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "check (%s,%s)", maker_note->make?maker_note->make:"", maker_note->model?maker_note->model:"");*/
|
||||
@@ -3747,6 +3757,10 @@ static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offse
|
||||
fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size);
|
||||
if (fgot < ImageInfo->Thumbnail.size) {
|
||||
EXIF_ERRLOG_THUMBEOF(ImageInfo)
|
||||
efree(ImageInfo->Thumbnail.data);
|
||||
ImageInfo->Thumbnail.data = NULL;
|
||||
} else {
|
||||
exif_thumbnail_build(ImageInfo);
|
||||
}
|
||||
exif_thumbnail_build(ImageInfo);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
--TEST--
|
||||
Bug #72627 (Memory Leakage In exif_process_IFD_in_TIFF)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||
--FILE--
|
||||
<?php
|
||||
$exif = exif_read_data(__DIR__ . '/bug72627.tiff',0,0,true);
|
||||
var_dump($exif);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: exif_read_data(%s): Thumbnail goes IFD boundary or end of file reached in %sbug72627.php on line %d
|
||||
|
||||
Warning: exif_read_data(%s): Error in TIFF: filesize(x04E2) less than start of IFD dir(x829A0004) in %sbug72627.php on line %d
|
||||
|
||||
Warning: exif_read_data(%s): Thumbnail goes IFD boundary or end of file reached in %sbug72627.php on line %d
|
||||
array(11) {
|
||||
["FileName"]=>
|
||||
string(13) "bug72627.tiff"
|
||||
["FileDateTime"]=>
|
||||
int(%d)
|
||||
["FileSize"]=>
|
||||
int(1250)
|
||||
["FileType"]=>
|
||||
int(7)
|
||||
["MimeType"]=>
|
||||
string(10) "image/tiff"
|
||||
["SectionsFound"]=>
|
||||
string(30) "ANY_TAG, IFD0, THUMBNAIL, EXIF"
|
||||
["COMPUTED"]=>
|
||||
array(10) {
|
||||
["html"]=>
|
||||
string(24) "width="128" height="132""
|
||||
["Height"]=>
|
||||
int(132)
|
||||
["Width"]=>
|
||||
int(128)
|
||||
["IsColor"]=>
|
||||
int(0)
|
||||
["ByteOrderMotorola"]=>
|
||||
int(0)
|
||||
["ApertureFNumber"]=>
|
||||
string(5) "f/1.0"
|
||||
["Thumbnail.FileType"]=>
|
||||
int(2)
|
||||
["Thumbnail.MimeType"]=>
|
||||
string(10) "image/jpeg"
|
||||
["Thumbnail.Height"]=>
|
||||
int(132)
|
||||
["Thumbnail.Width"]=>
|
||||
int(128)
|
||||
}
|
||||
["XResolution"]=>
|
||||
string(21) "1414812756/1414812756"
|
||||
["THUMBNAIL"]=>
|
||||
array(5) {
|
||||
["ImageWidth"]=>
|
||||
int(128)
|
||||
["ImageLength"]=>
|
||||
int(132)
|
||||
["JPEGInterchangeFormat"]=>
|
||||
int(1280)
|
||||
["JPEGInterchangeFormatLength"]=>
|
||||
int(100)
|
||||
["THUMBNAIL"]=>
|
||||
NULL
|
||||
}
|
||||
["ExposureTime"]=>
|
||||
string(21) "1414812756/1414812756"
|
||||
["FNumber"]=>
|
||||
string(21) "1414812756/1414812756"
|
||||
}
|
||||
Binary file not shown.
+8
-3
@@ -1530,11 +1530,11 @@ PHP_FUNCTION(imagetruecolortopalette)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (ncolors <= 0) {
|
||||
php_error_docref(NULL, E_WARNING, "Number of colors has to be greater than zero");
|
||||
if (ncolors <= 0 || ZEND_LONG_INT_OVFL(ncolors)) {
|
||||
php_error_docref(NULL, E_WARNING, "Number of colors has to be greater than zero and no more than %d", INT_MAX);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
gdImageTrueColorToPalette(im, dither, ncolors);
|
||||
gdImageTrueColorToPalette(im, dither, (int)ncolors);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@@ -3032,6 +3032,11 @@ PHP_FUNCTION(imagegammacorrect)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( input <= 0.0 || output <= 0.0 ) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Gamma values should be positive");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Bug #72697: select_colors write out-of-bounds
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists("imagecreatetruecolor")) die("skip");
|
||||
if (PHP_INT_MAX !== 9223372036854775807) die("skip for 64-bit long systems only");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$img=imagecreatetruecolor(10, 10);
|
||||
imagetruecolortopalette($img, false, PHP_INT_MAX / 8);
|
||||
?>
|
||||
DONE
|
||||
--EXPECTF--
|
||||
Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than 2147483647 in %sbug72697.php on line %d
|
||||
DONE
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #72730: imagegammacorrect allows arbitrary write access
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists("imagecreatetruecolor")) die("skip");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$img = imagecreatetruecolor(1, 1);
|
||||
imagegammacorrect($img, -1, 1337);
|
||||
?>
|
||||
DONE
|
||||
--EXPECTF--
|
||||
Warning: imagegammacorrect(): Gamma values should be positive in %sbug72730.php on line %d
|
||||
DONE
|
||||
@@ -25,4 +25,4 @@ Warning: imagetruecolortopalette() expects parameter 3 to be integer, resource g
|
||||
|
||||
Warning: imagetruecolortopalette() expects parameter 3 to be integer, array given in %s on line %d
|
||||
|
||||
Warning: imagetruecolortopalette(): Number of colors has to be greater than zero in %s on line %d
|
||||
Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s on line %d
|
||||
@@ -16,6 +16,6 @@ imagetruecolortopalette($image, true, -1);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: imagetruecolortopalette(): Number of colors has to be greater than zero in %s on line %d
|
||||
Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s line %d
|
||||
|
||||
Warning: imagetruecolortopalette(): Number of colors has to be greater than zero in %s on line %d
|
||||
Warning: imagetruecolortopalette(): Number of colors has to be greater than zero and no more than %d in %s line %d
|
||||
+8
-8
@@ -633,6 +633,10 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
RETURN_FALSE
|
||||
}
|
||||
|
||||
if (data_len > INT_MAX) {
|
||||
php_error_docref(NULL, E_WARNING, "Data size too large, %d maximum", INT_MAX);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* Check blocksize */
|
||||
if (mcrypt_enc_is_block_mode(pm->td) == 1) { /* It's a block algorithm */
|
||||
block_size = mcrypt_enc_get_block_size(pm->td);
|
||||
@@ -645,10 +649,6 @@ PHP_FUNCTION(mcrypt_generic)
|
||||
memset(ZSTR_VAL(data_str), 0, data_size);
|
||||
memcpy(ZSTR_VAL(data_str), data, data_len);
|
||||
} else { /* It's not a block algorithm */
|
||||
if (data_len > INT_MAX) {
|
||||
php_error_docref(NULL, E_WARNING, "Data size too large, %d maximum", INT_MAX);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
data_size = (int)data_len;
|
||||
data_str = zend_string_alloc(data_size, 0);
|
||||
memset(ZSTR_VAL(data_str), 0, data_size);
|
||||
@@ -688,6 +688,10 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
}
|
||||
|
||||
/* Check blocksize */
|
||||
if (data_len > INT_MAX) {
|
||||
php_error_docref(NULL, E_WARNING, "Data size too large, %d maximum", INT_MAX);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (mcrypt_enc_is_block_mode(pm->td) == 1) { /* It's a block algorithm */
|
||||
block_size = mcrypt_enc_get_block_size(pm->td);
|
||||
data_size = ((((int)data_len - 1) / block_size) + 1) * block_size;
|
||||
@@ -699,10 +703,6 @@ PHP_FUNCTION(mdecrypt_generic)
|
||||
memset(data_s, 0, data_size);
|
||||
memcpy(data_s, data, data_len);
|
||||
} else { /* It's not a block algorithm */
|
||||
if (data_len > INT_MAX) {
|
||||
php_error_docref(NULL, E_WARNING, "Data size too large, %d maximum", INT_MAX);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
data_size = (int)data_len;
|
||||
data_s = emalloc(data_size + 1);
|
||||
memset(data_s, 0, data_size);
|
||||
|
||||
@@ -361,30 +361,31 @@ static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t *
|
||||
{
|
||||
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
|
||||
char *id = NULL;
|
||||
PGresult *res;
|
||||
ExecStatusType status;
|
||||
const char *q[1];
|
||||
q[0] = name;
|
||||
|
||||
if (PHP_PDO_PGSQL_LASTVAL_PG_VERSION <= PQserverVersion(H->server) && name == NULL) {
|
||||
res = PQexec(H->server, "SELECT LASTVAL()");
|
||||
} else {
|
||||
res = PQexecParams(H->server, "SELECT CURRVAL($1)", 1, NULL, q, NULL, NULL, 0);
|
||||
}
|
||||
status = PQresultStatus(res);
|
||||
|
||||
if (res && (status == PGRES_TUPLES_OK)) {
|
||||
id = estrdup((char *)PQgetvalue(res, 0, 0));
|
||||
*len = PQgetlength(res, 0, 0);
|
||||
} else {
|
||||
pdo_pgsql_error(dbh, status, pdo_pgsql_sqlstate(res));
|
||||
if (name == NULL) {
|
||||
if (H->pgoid == InvalidOid) {
|
||||
return NULL;
|
||||
}
|
||||
*len = spprintf(&id, 0, ZEND_LONG_FMT, (zend_long) H->pgoid);
|
||||
}
|
||||
} else {
|
||||
PGresult *res;
|
||||
ExecStatusType status;
|
||||
const char *q[1];
|
||||
q[0] = name;
|
||||
res = PQexecParams(H->server, "SELECT CURRVAL($1)", 1, NULL, q, NULL, NULL, 0);
|
||||
status = PQresultStatus(res);
|
||||
|
||||
if (res) {
|
||||
PQclear(res);
|
||||
}
|
||||
if (res && (status == PGRES_TUPLES_OK)) {
|
||||
id = estrdup((char *)PQgetvalue(res, 0, 0));
|
||||
*len = PQgetlength(res, 0, 0);
|
||||
} else {
|
||||
pdo_pgsql_error(dbh, status, pdo_pgsql_sqlstate(res));
|
||||
}
|
||||
|
||||
if (res) {
|
||||
PQclear(res);
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
#define PHP_PDO_PGSQL_CONNECTION_FAILURE_SQLSTATE "08006"
|
||||
|
||||
#define PHP_PDO_PGSQL_LASTVAL_PG_VERSION 80100
|
||||
|
||||
typedef struct {
|
||||
const char *file;
|
||||
int line;
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
--TEST--
|
||||
currval() vs lastval() - PDO PgSQL Bug #1134 [BUG] New record, PostgreSQL and the Primary key https://github.com/phalcon/cphalcon/issues/1134
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
|
||||
require dirname(__FILE__) . '/config.inc';
|
||||
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
|
||||
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
|
||||
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
|
||||
|
||||
$db->query('CREATE TABLE test_last_id (id SERIAL NOT NULL, field1 VARCHAR(10))');
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO test_last_id (field1) VALUES ('test')");
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
/**
|
||||
* No sequence name informed
|
||||
*/
|
||||
var_dump($db->lastInsertId());
|
||||
/**
|
||||
* Sequence name informed
|
||||
*/
|
||||
var_dump($db->lastInsertId('test_last_id_id_seq'));
|
||||
|
||||
$db->query('DROP TABLE test_last_id');
|
||||
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
string\([0-9]*\)\ \"[0-9]*\"
|
||||
string\([0-9]*\)\ \"[0-9]*\"
|
||||
@@ -5,7 +5,7 @@ Postgres
|
||||
if (!extension_loaded('pdo_pgsql')) print 'skip'; ?>
|
||||
--REDIRECTTEST--
|
||||
# magic auto-configuration
|
||||
# Also update config.inc if you make changes here...
|
||||
# Also update config.inc if you make changes here...
|
||||
|
||||
$config = array(
|
||||
'TESTS' => __DIR__ . '/ext/pdo/tests'
|
||||
@@ -20,5 +20,5 @@ if (false !== getenv('PDO_PGSQL_TEST_DSN')) {
|
||||
} else {
|
||||
$config['ENV']['PDOTEST_DSN'] = 'pgsql:host=localhost port=5432 dbname=test user= password=';
|
||||
}
|
||||
|
||||
|
||||
return $config;
|
||||
+23
-8
@@ -905,12 +905,19 @@ PS_SERIALIZER_DECODE_FUNC(php_serialize) /* {{{ */
|
||||
const char *endptr = val + vallen;
|
||||
zval session_vars;
|
||||
php_unserialize_data_t var_hash;
|
||||
int result;
|
||||
zend_string *var_name = zend_string_init("_SESSION", sizeof("_SESSION") - 1, 0);
|
||||
|
||||
ZVAL_NULL(&session_vars);
|
||||
PHP_VAR_UNSERIALIZE_INIT(var_hash);
|
||||
php_var_unserialize(&session_vars, (const unsigned char **)&val, (const unsigned char *)endptr, &var_hash);
|
||||
result = php_var_unserialize(
|
||||
&session_vars, (const unsigned char **)&val, (const unsigned char *)endptr, &var_hash);
|
||||
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
|
||||
if (!result) {
|
||||
zval_ptr_dtor(&session_vars);
|
||||
ZVAL_NULL(&session_vars);
|
||||
}
|
||||
|
||||
if (!Z_ISUNDEF(PS(http_session_vars))) {
|
||||
zval_ptr_dtor(&PS(http_session_vars));
|
||||
}
|
||||
@@ -963,11 +970,13 @@ PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */
|
||||
int namelen;
|
||||
zend_string *name;
|
||||
php_unserialize_data_t var_hash;
|
||||
int skip = 0;
|
||||
|
||||
PHP_VAR_UNSERIALIZE_INIT(var_hash);
|
||||
|
||||
for (p = val; p < endptr; ) {
|
||||
zval *tmp;
|
||||
skip = 0;
|
||||
namelen = ((unsigned char)(*p)) & (~PS_BIN_UNDEF);
|
||||
|
||||
if (namelen < 0 || namelen > PS_BIN_MAX || (p + namelen) >= endptr) {
|
||||
@@ -984,8 +993,7 @@ PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */
|
||||
if ((tmp = zend_hash_find(&EG(symbol_table), name))) {
|
||||
if ((Z_TYPE_P(tmp) == IS_ARRAY &&
|
||||
Z_ARRVAL_P(tmp) == &EG(symbol_table)) || tmp == &PS(http_session_vars)) {
|
||||
zend_string_release(name);
|
||||
continue;
|
||||
skip = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,7 +1002,9 @@ PS_SERIALIZER_DECODE_FUNC(php_binary) /* {{{ */
|
||||
current = var_tmp_var(&var_hash);
|
||||
if (php_var_unserialize(current, (const unsigned char **) &p, (const unsigned char *) endptr, &var_hash)) {
|
||||
ZVAL_PTR(&rv, current);
|
||||
php_set_session_var(name, &rv, &var_hash );
|
||||
if (!skip) {
|
||||
php_set_session_var(name, &rv, &var_hash);
|
||||
}
|
||||
} else {
|
||||
zend_string_release(name);
|
||||
php_session_normalize_vars();
|
||||
@@ -1056,6 +1066,7 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
|
||||
zend_string *name;
|
||||
int has_value, retval = SUCCESS;
|
||||
php_unserialize_data_t var_hash;
|
||||
int skip = 0;
|
||||
|
||||
PHP_VAR_UNSERIALIZE_INIT(var_hash);
|
||||
|
||||
@@ -1064,6 +1075,7 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
|
||||
while (p < endptr) {
|
||||
zval *tmp;
|
||||
q = p;
|
||||
skip = 0;
|
||||
while (*q != PS_DELIMITER) {
|
||||
if (++q >= endptr) goto break_outer_loop;
|
||||
}
|
||||
@@ -1081,7 +1093,7 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
|
||||
if ((tmp = zend_hash_find(&EG(symbol_table), name))) {
|
||||
if ((Z_TYPE_P(tmp) == IS_ARRAY &&
|
||||
Z_ARRVAL_P(tmp) == &EG(symbol_table)) || tmp == &PS(http_session_vars)) {
|
||||
goto skip;
|
||||
skip = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1090,16 +1102,19 @@ PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
|
||||
current = var_tmp_var(&var_hash);
|
||||
if (php_var_unserialize(current, (const unsigned char **)&q, (const unsigned char *)endptr, &var_hash)) {
|
||||
ZVAL_PTR(&rv, current);
|
||||
php_set_session_var(name, &rv, &var_hash);
|
||||
if (!skip) {
|
||||
php_set_session_var(name, &rv, &var_hash);
|
||||
}
|
||||
} else {
|
||||
zend_string_release(name);
|
||||
retval = FAILURE;
|
||||
goto break_outer_loop;
|
||||
}
|
||||
} else {
|
||||
PS_ADD_VARL(name);
|
||||
if(!skip) {
|
||||
PS_ADD_VARL(name);
|
||||
}
|
||||
}
|
||||
skip:
|
||||
zend_string_release(name);
|
||||
|
||||
p = q;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Bug #72681: PHP Session Data Injection Vulnerability
|
||||
--SKIPIF--
|
||||
<?php include('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set('session.serialize_handler', 'php');
|
||||
session_start();
|
||||
$GLOBALS['ryat'] = $GLOBALS;
|
||||
$_SESSION['ryat'] = 'ryat|O:8:"stdClass":0:{}';
|
||||
session_write_close();
|
||||
session_start();
|
||||
var_dump($_SESSION);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(0) {
|
||||
}
|
||||
+1
-1
@@ -1011,7 +1011,7 @@ static int php_snmp_parse_oid(zval *object, int st, struct objid_query *objid_qu
|
||||
php_error_docref(NULL, E_WARNING, "Got empty OID array");
|
||||
return FALSE;
|
||||
}
|
||||
objid_query->vars = (snmpobjarg *)emalloc(sizeof(snmpobjarg) * zend_hash_num_elements(Z_ARRVAL_P(oid)));
|
||||
objid_query->vars = (snmpobjarg *)safe_emalloc(sizeof(snmpobjarg), zend_hash_num_elements(Z_ARRVAL_P(oid)), 0);
|
||||
if (objid_query->vars == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "emalloc() failed while parsing oid array: %s", strerror(errno));
|
||||
efree(objid_query->vars);
|
||||
|
||||
@@ -187,7 +187,8 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char
|
||||
/* get the response */
|
||||
result = GET_FTP_RESULT(stream);
|
||||
if (result != 334) {
|
||||
use_ssl = 0;
|
||||
php_stream_wrapper_log_error(wrapper, options, "Server doesn't support FTPS.");
|
||||
goto connect_errexit;
|
||||
} else {
|
||||
/* we must reuse the old SSL session id */
|
||||
/* if we talk to an old ftpd-ssl */
|
||||
@@ -707,7 +708,7 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char *pat
|
||||
if (result > 299 || result < 200)
|
||||
goto opendir_errexit;
|
||||
|
||||
// tmp_line isn't relevant after the php_fopen_do_pasv().
|
||||
// tmp_line isn't relevant after the php_fopen_do_pasv().
|
||||
tmp_line[0] = '\0';
|
||||
|
||||
/* set up the passive connection */
|
||||
@@ -735,7 +736,7 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char *pat
|
||||
php_stream_wrapper_log_error(wrapper, options, "Unable to activate SSL mode");
|
||||
php_stream_close(datastream);
|
||||
datastream = NULL;
|
||||
goto opendir_errexit;
|
||||
goto opendir_errexit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
--TEST--
|
||||
Bug #72663 (1): Don't call __destruct if __wakeup not called or fails
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Test1 {
|
||||
public function __wakeup() {
|
||||
echo "Wakeup\n";
|
||||
}
|
||||
public function __destruct() {
|
||||
echo "Dtor\n";
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 {
|
||||
public function __wakeup() {
|
||||
throw new Exception('Unserialization forbidden');
|
||||
}
|
||||
public function __destruct() {
|
||||
echo "Dtor\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Unserialize object with error in properties
|
||||
$s = 'O:5:"Test1":1:{s:10:"";}';
|
||||
var_dump(unserialize($s));
|
||||
|
||||
// Variation: Object is turned into a reference
|
||||
$s = 'O:5:"Test1":2:{i:0;R:1;s:10:"";}';
|
||||
var_dump(unserialize($s));
|
||||
|
||||
// Unserialize object with throwing __wakeup
|
||||
$s = 'O:5:"Test2":0:{}';
|
||||
try {
|
||||
var_dump(unserialize($s));
|
||||
} catch (Exception $e) {
|
||||
echo "Caught\n";
|
||||
}
|
||||
//
|
||||
// Variation: Object is turned into a reference
|
||||
$s = 'O:5:"Test2":1:{i:0;R:1;}';
|
||||
try {
|
||||
var_dump(unserialize($s));
|
||||
} catch (Exception $e) {
|
||||
echo "Caught\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Notice: unserialize(): Error at offset 17 of 24 bytes in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Notice: unserialize(): Error at offset 25 of 32 bytes in %s on line %d
|
||||
bool(false)
|
||||
Caught
|
||||
Caught
|
||||
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
Bug #72663 (2): Don't allow references into failed unserialize
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class obj implements Serializable {
|
||||
public $data;
|
||||
function serialize() {
|
||||
return serialize($this->data);
|
||||
}
|
||||
function unserialize($data) {
|
||||
$this->data = unserialize($data);
|
||||
}
|
||||
}
|
||||
|
||||
$inner = 'a:1:{i:0;O:9:"Exception":2:{s:7:"'."\0".'*'."\0".'file";R:4;}';
|
||||
$exploit = 'a:2:{i:0;C:3:"obj":'.strlen($inner).':{'.$inner.'}i:1;R:4;}';
|
||||
var_dump(unserialize($exploit));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Notice: unserialize(): Unexpected end of serialized data in %s on line %d
|
||||
|
||||
Notice: unserialize(): Error at offset 46 of 47 bytes in %s on line %d
|
||||
|
||||
Notice: unserialize(): Error at offset 79 of 80 bytes in %s on line %d
|
||||
bool(false)
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Bug #72663 (3): If unserialization fails, don't initialize the session with the result
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('session')) die('skip Session extension required'); ?>
|
||||
--INI--
|
||||
session.serialize_handler=php_serialize
|
||||
--FILE--
|
||||
<?php
|
||||
session_start();
|
||||
$sess = 'O:9:"Exception":2:{s:7:"'."\0".'*'."\0".'file";R:1;}';
|
||||
session_decode($sess);
|
||||
var_dump($_SESSION);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Notice: session_decode(): Unexpected end of serialized data in %s on line %d
|
||||
array(0) {
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #72663: Create an Unexpected Object and Don't Invoke __wakeup() in Deserialization
|
||||
--FILE--
|
||||
<?php
|
||||
class obj implements Serializable {
|
||||
var $data;
|
||||
function serialize() {
|
||||
return serialize($this->data);
|
||||
}
|
||||
function unserialize($data) {
|
||||
$this->data = unserialize($data);
|
||||
}
|
||||
}
|
||||
|
||||
$inner = 'a:1:{i:0;O:9:"Exception":2:{s:7:"'."\0".'*'."\0".'file";R:4;}';
|
||||
$exploit = 'a:2:{i:0;C:3:"obj":'.strlen($inner).':{'.$inner.'}i:1;R:4;}';
|
||||
|
||||
$data = unserialize($exploit);
|
||||
echo $data[1];
|
||||
?>
|
||||
DONE
|
||||
--EXPECTF--
|
||||
Notice: unserialize(): Unexpected end of serialized data in %sbug72663.php on line %d
|
||||
|
||||
Notice: unserialize(): Error at offset 46 of 47 bytes in %sbug72663.php on line %d
|
||||
|
||||
Notice: unserialize(): Error at offset 79 of 80 bytes in %sbug72663.php on line %d
|
||||
DONE
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Bug #72663: Create an Unexpected Object and Don't Invoke __wakeup() in Deserialization
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
ini_set('session.serialize_handler', 'php_serialize');
|
||||
session_start();
|
||||
$sess = 'O:9:"Exception":2:{s:7:"'."\0".'*'."\0".'file";R:1;}';
|
||||
session_decode($sess);
|
||||
var_dump($_SESSION);
|
||||
?>
|
||||
DONE
|
||||
--EXPECTF--
|
||||
Notice: session_decode(): Unexpected end of serialized data in %sbug72663_2.php on line %d
|
||||
array(0) {
|
||||
}
|
||||
DONE
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Generated by re2c 0.13.5 */
|
||||
/* Generated by re2c 0.13.7.5 */
|
||||
#line 1 "ext/standard/var_unserializer.re"
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
@@ -301,6 +301,8 @@ static inline size_t parse_uiv(const unsigned char *p)
|
||||
#define UNSERIALIZE_PARAMETER zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash, HashTable *classes
|
||||
#define UNSERIALIZE_PASSTHRU rval, p, max, var_hash, classes
|
||||
|
||||
static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER);
|
||||
|
||||
static zend_always_inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, zend_long elements, int objprops)
|
||||
{
|
||||
while (elements-- > 0) {
|
||||
@@ -309,7 +311,7 @@ static zend_always_inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTab
|
||||
|
||||
ZVAL_UNDEF(&key);
|
||||
|
||||
if (!php_var_unserialize_ex(&key, p, max, NULL, classes)) {
|
||||
if (!php_var_unserialize_internal(&key, p, max, NULL, classes)) {
|
||||
zval_dtor(&key);
|
||||
return 0;
|
||||
}
|
||||
@@ -365,7 +367,7 @@ string_key:
|
||||
}
|
||||
}
|
||||
|
||||
if (!php_var_unserialize_ex(data, p, max, var_hash, classes)) {
|
||||
if (!php_var_unserialize_internal(data, p, max, var_hash, classes)) {
|
||||
zval_dtor(&key);
|
||||
return 0;
|
||||
}
|
||||
@@ -455,23 +457,32 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements)
|
||||
zval retval;
|
||||
zval fname;
|
||||
HashTable *ht;
|
||||
zend_bool has_wakeup;
|
||||
|
||||
if (Z_TYPE_P(rval) != IS_OBJECT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
has_wakeup = Z_OBJCE_P(rval) != PHP_IC_ENTRY
|
||||
&& zend_hash_str_exists(&Z_OBJCE_P(rval)->function_table, "__wakeup", sizeof("__wakeup")-1);
|
||||
|
||||
ht = Z_OBJPROP_P(rval);
|
||||
zend_hash_extend(ht, zend_hash_num_elements(ht) + elements, (ht->u.flags & HASH_FLAG_PACKED));
|
||||
if (!process_nested_data(UNSERIALIZE_PASSTHRU, ht, elements, 1)) {
|
||||
if (has_wakeup) {
|
||||
ZVAL_DEREF(rval);
|
||||
GC_FLAGS(Z_OBJ_P(rval)) |= IS_OBJ_DESTRUCTOR_CALLED;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZVAL_DEREF(rval);
|
||||
if (Z_OBJCE_P(rval) != PHP_IC_ENTRY &&
|
||||
zend_hash_str_exists(&Z_OBJCE_P(rval)->function_table, "__wakeup", sizeof("__wakeup")-1)) {
|
||||
if (has_wakeup) {
|
||||
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1);
|
||||
BG(serialize_lock)++;
|
||||
call_user_function_ex(CG(function_table), rval, &fname, &retval, 0, 0, 1, NULL);
|
||||
if (call_user_function_ex(CG(function_table), rval, &fname, &retval, 0, 0, 1, NULL) == FAILURE || Z_ISUNDEF(retval)) {
|
||||
GC_FLAGS(Z_OBJ_P(rval)) |= IS_OBJ_DESTRUCTOR_CALLED;
|
||||
}
|
||||
BG(serialize_lock)--;
|
||||
zval_dtor(&fname);
|
||||
zval_dtor(&retval);
|
||||
@@ -482,7 +493,6 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements)
|
||||
}
|
||||
|
||||
return finish_nested_data(UNSERIALIZE_PASSTHRU);
|
||||
|
||||
}
|
||||
#ifdef PHP_WIN32
|
||||
# pragma optimize("", on)
|
||||
@@ -494,8 +504,34 @@ PHPAPI int php_var_unserialize(zval *rval, const unsigned char **p, const unsign
|
||||
return php_var_unserialize_ex(UNSERIALIZE_PASSTHRU);
|
||||
}
|
||||
|
||||
|
||||
PHPAPI int php_var_unserialize_ex(UNSERIALIZE_PARAMETER)
|
||||
{
|
||||
var_entries *orig_var_entries = (*var_hash)->last;
|
||||
zend_long orig_used_slots = orig_var_entries ? orig_var_entries->used_slots : 0;
|
||||
int result;
|
||||
|
||||
result = php_var_unserialize_internal(UNSERIALIZE_PASSTHRU);
|
||||
|
||||
if (!result) {
|
||||
/* If the unserialization failed, mark all elements that have been added to var_hash
|
||||
* as NULL. This will forbid their use by other unserialize() calls in the same
|
||||
* unserialization context. */
|
||||
var_entries *e = orig_var_entries;
|
||||
zend_long s = orig_used_slots;
|
||||
while (e) {
|
||||
for (; s < e->used_slots; s++) {
|
||||
e->data[s] = NULL;
|
||||
}
|
||||
|
||||
e = e->next;
|
||||
s = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
|
||||
{
|
||||
const unsigned char *cursor, *limit, *marker, *start;
|
||||
zval *rval_ref;
|
||||
@@ -514,7 +550,7 @@ PHPAPI int php_var_unserialize_ex(UNSERIALIZE_PARAMETER)
|
||||
start = cursor;
|
||||
|
||||
|
||||
#line 518 "ext/standard/var_unserializer.c"
|
||||
#line 554 "ext/standard/var_unserializer.c"
|
||||
{
|
||||
YYCTYPE yych;
|
||||
static const unsigned char yybm[] = {
|
||||
@@ -651,7 +687,8 @@ yy20:
|
||||
if (yybm[0+yych] & 128) {
|
||||
goto yy20;
|
||||
}
|
||||
if (yych != ':') goto yy18;
|
||||
if (yych <= '/') goto yy18;
|
||||
if (yych >= ';') goto yy18;
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != '"') goto yy18;
|
||||
++YYCURSOR;
|
||||
@@ -800,7 +837,7 @@ yy20:
|
||||
|
||||
return object_common2(UNSERIALIZE_PASSTHRU, elements);
|
||||
}
|
||||
#line 804 "ext/standard/var_unserializer.c"
|
||||
#line 805 "ext/standard/var_unserializer.c"
|
||||
yy25:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= ',') {
|
||||
@@ -832,7 +869,7 @@ yy27:
|
||||
return object_common2(UNSERIALIZE_PASSTHRU,
|
||||
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
|
||||
}
|
||||
#line 836 "ext/standard/var_unserializer.c"
|
||||
#line 837 "ext/standard/var_unserializer.c"
|
||||
yy32:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == '+') goto yy33;
|
||||
@@ -877,7 +914,7 @@ yy34:
|
||||
|
||||
return finish_nested_data(UNSERIALIZE_PASSTHRU);
|
||||
}
|
||||
#line 881 "ext/standard/var_unserializer.c"
|
||||
#line 882 "ext/standard/var_unserializer.c"
|
||||
yy39:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == '+') goto yy40;
|
||||
@@ -932,7 +969,7 @@ yy41:
|
||||
ZVAL_STR(rval, str);
|
||||
return 1;
|
||||
}
|
||||
#line 936 "ext/standard/var_unserializer.c"
|
||||
#line 937 "ext/standard/var_unserializer.c"
|
||||
yy46:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == '+') goto yy47;
|
||||
@@ -985,7 +1022,7 @@ yy48:
|
||||
ZVAL_STRINGL(rval, str, len);
|
||||
return 1;
|
||||
}
|
||||
#line 989 "ext/standard/var_unserializer.c"
|
||||
#line 990 "ext/standard/var_unserializer.c"
|
||||
yy53:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') {
|
||||
@@ -1082,7 +1119,7 @@ use_double:
|
||||
ZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL));
|
||||
return 1;
|
||||
}
|
||||
#line 1086 "ext/standard/var_unserializer.c"
|
||||
#line 1087 "ext/standard/var_unserializer.c"
|
||||
yy65:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= ',') {
|
||||
@@ -1157,7 +1194,7 @@ yy73:
|
||||
|
||||
return 1;
|
||||
}
|
||||
#line 1161 "ext/standard/var_unserializer.c"
|
||||
#line 1162 "ext/standard/var_unserializer.c"
|
||||
yy76:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == 'N') goto yy73;
|
||||
@@ -1210,7 +1247,7 @@ yy79:
|
||||
ZVAL_LONG(rval, parse_iv(start + 2));
|
||||
return 1;
|
||||
}
|
||||
#line 1214 "ext/standard/var_unserializer.c"
|
||||
#line 1215 "ext/standard/var_unserializer.c"
|
||||
yy83:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= '/') goto yy18;
|
||||
@@ -1224,7 +1261,7 @@ yy83:
|
||||
ZVAL_BOOL(rval, parse_iv(start + 2));
|
||||
return 1;
|
||||
}
|
||||
#line 1228 "ext/standard/var_unserializer.c"
|
||||
#line 1229 "ext/standard/var_unserializer.c"
|
||||
yy87:
|
||||
++YYCURSOR;
|
||||
#line 573 "ext/standard/var_unserializer.re"
|
||||
@@ -1233,7 +1270,7 @@ yy87:
|
||||
ZVAL_NULL(rval);
|
||||
return 1;
|
||||
}
|
||||
#line 1237 "ext/standard/var_unserializer.c"
|
||||
#line 1238 "ext/standard/var_unserializer.c"
|
||||
yy89:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= ',') {
|
||||
@@ -1281,7 +1318,7 @@ yy91:
|
||||
|
||||
return 1;
|
||||
}
|
||||
#line 1285 "ext/standard/var_unserializer.c"
|
||||
#line 1286 "ext/standard/var_unserializer.c"
|
||||
yy95:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych <= ',') {
|
||||
@@ -1330,7 +1367,7 @@ yy97:
|
||||
|
||||
return 1;
|
||||
}
|
||||
#line 1334 "ext/standard/var_unserializer.c"
|
||||
#line 1335 "ext/standard/var_unserializer.c"
|
||||
}
|
||||
#line 886 "ext/standard/var_unserializer.re"
|
||||
|
||||
|
||||
@@ -305,6 +305,8 @@ static inline size_t parse_uiv(const unsigned char *p)
|
||||
#define UNSERIALIZE_PARAMETER zval *rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash, HashTable *classes
|
||||
#define UNSERIALIZE_PASSTHRU rval, p, max, var_hash, classes
|
||||
|
||||
static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER);
|
||||
|
||||
static zend_always_inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, zend_long elements, int objprops)
|
||||
{
|
||||
while (elements-- > 0) {
|
||||
@@ -313,7 +315,7 @@ static zend_always_inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTab
|
||||
|
||||
ZVAL_UNDEF(&key);
|
||||
|
||||
if (!php_var_unserialize_ex(&key, p, max, NULL, classes)) {
|
||||
if (!php_var_unserialize_internal(&key, p, max, NULL, classes)) {
|
||||
zval_dtor(&key);
|
||||
return 0;
|
||||
}
|
||||
@@ -369,7 +371,7 @@ string_key:
|
||||
}
|
||||
}
|
||||
|
||||
if (!php_var_unserialize_ex(data, p, max, var_hash, classes)) {
|
||||
if (!php_var_unserialize_internal(data, p, max, var_hash, classes)) {
|
||||
zval_dtor(&key);
|
||||
return 0;
|
||||
}
|
||||
@@ -459,23 +461,32 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements)
|
||||
zval retval;
|
||||
zval fname;
|
||||
HashTable *ht;
|
||||
zend_bool has_wakeup;
|
||||
|
||||
if (Z_TYPE_P(rval) != IS_OBJECT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
has_wakeup = Z_OBJCE_P(rval) != PHP_IC_ENTRY
|
||||
&& zend_hash_str_exists(&Z_OBJCE_P(rval)->function_table, "__wakeup", sizeof("__wakeup")-1);
|
||||
|
||||
ht = Z_OBJPROP_P(rval);
|
||||
zend_hash_extend(ht, zend_hash_num_elements(ht) + elements, (ht->u.flags & HASH_FLAG_PACKED));
|
||||
if (!process_nested_data(UNSERIALIZE_PASSTHRU, ht, elements, 1)) {
|
||||
if (has_wakeup) {
|
||||
ZVAL_DEREF(rval);
|
||||
GC_FLAGS(Z_OBJ_P(rval)) |= IS_OBJ_DESTRUCTOR_CALLED;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZVAL_DEREF(rval);
|
||||
if (Z_OBJCE_P(rval) != PHP_IC_ENTRY &&
|
||||
zend_hash_str_exists(&Z_OBJCE_P(rval)->function_table, "__wakeup", sizeof("__wakeup")-1)) {
|
||||
if (has_wakeup) {
|
||||
ZVAL_STRINGL(&fname, "__wakeup", sizeof("__wakeup") - 1);
|
||||
BG(serialize_lock)++;
|
||||
call_user_function_ex(CG(function_table), rval, &fname, &retval, 0, 0, 1, NULL);
|
||||
if (call_user_function_ex(CG(function_table), rval, &fname, &retval, 0, 0, 1, NULL) == FAILURE || Z_ISUNDEF(retval)) {
|
||||
GC_FLAGS(Z_OBJ_P(rval)) |= IS_OBJ_DESTRUCTOR_CALLED;
|
||||
}
|
||||
BG(serialize_lock)--;
|
||||
zval_dtor(&fname);
|
||||
zval_dtor(&retval);
|
||||
@@ -486,7 +497,6 @@ static inline int object_common2(UNSERIALIZE_PARAMETER, zend_long elements)
|
||||
}
|
||||
|
||||
return finish_nested_data(UNSERIALIZE_PASSTHRU);
|
||||
|
||||
}
|
||||
#ifdef PHP_WIN32
|
||||
# pragma optimize("", on)
|
||||
@@ -498,8 +508,34 @@ PHPAPI int php_var_unserialize(zval *rval, const unsigned char **p, const unsign
|
||||
return php_var_unserialize_ex(UNSERIALIZE_PASSTHRU);
|
||||
}
|
||||
|
||||
|
||||
PHPAPI int php_var_unserialize_ex(UNSERIALIZE_PARAMETER)
|
||||
{
|
||||
var_entries *orig_var_entries = (*var_hash)->last;
|
||||
zend_long orig_used_slots = orig_var_entries ? orig_var_entries->used_slots : 0;
|
||||
int result;
|
||||
|
||||
result = php_var_unserialize_internal(UNSERIALIZE_PASSTHRU);
|
||||
|
||||
if (!result) {
|
||||
/* If the unserialization failed, mark all elements that have been added to var_hash
|
||||
* as NULL. This will forbid their use by other unserialize() calls in the same
|
||||
* unserialization context. */
|
||||
var_entries *e = orig_var_entries;
|
||||
zend_long s = orig_used_slots;
|
||||
while (e) {
|
||||
for (; s < e->used_slots; s++) {
|
||||
e->data[s] = NULL;
|
||||
}
|
||||
|
||||
e = e->next;
|
||||
s = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int php_var_unserialize_internal(UNSERIALIZE_PARAMETER)
|
||||
{
|
||||
const unsigned char *cursor, *limit, *marker, *start;
|
||||
zval *rval_ref;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Bug #72749: wddx_deserialize allows illegal memory access
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('wddx')) {
|
||||
die('skip. wddx not available');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$xml = <<<XML
|
||||
<?xml version='1.0'?>
|
||||
<!DOCTYPE wddxPacket SYSTEM 'wddx_0100.dtd'>
|
||||
<wddxPacket version='1.0'>
|
||||
<header/>
|
||||
<data>
|
||||
<struct>
|
||||
<var name='aDateTime3'>
|
||||
<dateTime>2\r2004-09-10T05:52:49+00</dateTime>
|
||||
</var>
|
||||
</struct>
|
||||
</data>
|
||||
</wddxPacket>
|
||||
XML;
|
||||
|
||||
$array = wddx_deserialize($xml);
|
||||
var_dump($array);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
["aDateTime3"]=>
|
||||
string(24) "2
|
||||
2004-09-10T05:52:49+00"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Bug #72750: wddx_deserialize null dereference
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('wddx')) {
|
||||
die('skip. wddx not available');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$xml = <<< XML
|
||||
<?xml version='1.0'?>
|
||||
<!DOCTYPE wddxPacket SYSTEM 'wddx_0100.dtd'>
|
||||
<wddxPacket version='1.0'>
|
||||
<header/>
|
||||
<data>
|
||||
<struct>
|
||||
<var name='aBinary'>
|
||||
<binary length='11'>\\tYmluYXJRhdGE=</binary>
|
||||
</var>
|
||||
</struct>
|
||||
</data>
|
||||
</wddxPacket>
|
||||
XML;
|
||||
|
||||
$array = wddx_deserialize($xml);
|
||||
var_dump($array);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
["aBinary"]=>
|
||||
string(0) ""
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
--TEST--
|
||||
Bug 72790: wddx_deserialize null dereference with invalid xml
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('wddx')) {
|
||||
die('skip. wddx not available');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$xml = <<< XML
|
||||
<?xml version='1.0' ?>
|
||||
<!DOCTYPE wddxPacket SYSTEM 'wddx_0100.dtd'>
|
||||
<wddxPacket version='1.0'>
|
||||
|array>
|
||||
<var name="XXXX">
|
||||
<boolean value="this">
|
||||
</boolean>
|
||||
</var>
|
||||
<var name="YYYY">
|
||||
<var name="UUUU">
|
||||
<var name="EZEZ">
|
||||
</var>
|
||||
</var>
|
||||
</var>
|
||||
</array>
|
||||
</wddxPacket>
|
||||
XML;
|
||||
|
||||
$array = wddx_deserialize($xml);
|
||||
var_dump($array);
|
||||
?>
|
||||
--EXPECT--
|
||||
NULL
|
||||
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #72799: wddx_deserialize null dereference in php_wddx_pop_element
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('wddx')) {
|
||||
die('skip. wddx not available');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$xml = <<<XML
|
||||
<?xml version='1.0'?>
|
||||
<!DOCTYPE wddxPacket SYSTEM 'wddx_0100.dtd'>
|
||||
<wddxPacket version="1.0">
|
||||
<var name="XXXX">
|
||||
<boolean value="1">
|
||||
<dateTime>1998-06-12T04:32:12+00</dateTime>
|
||||
</boolean>
|
||||
</var>
|
||||
</wddxPacket>
|
||||
XML;
|
||||
|
||||
$array = wddx_deserialize($xml);
|
||||
var_dump($array);
|
||||
?>
|
||||
--EXPECT--
|
||||
NULL
|
||||
+24
-8
@@ -886,10 +886,10 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
|
||||
if (Z_TYPE(ent1->data) == IS_UNDEF) {
|
||||
if (stack->top > 1) {
|
||||
stack->top--;
|
||||
efree(ent1);
|
||||
} else {
|
||||
stack->done = 1;
|
||||
}
|
||||
efree(ent1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -897,7 +897,11 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
|
||||
zend_string *new_str = php_base64_decode(
|
||||
(unsigned char *)Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
|
||||
zval_ptr_dtor(&ent1->data);
|
||||
ZVAL_STR(&ent1->data, new_str);
|
||||
if (new_str) {
|
||||
ZVAL_STR(&ent1->data, new_str);
|
||||
} else {
|
||||
ZVAL_EMPTY_STRING(&ent1->data);
|
||||
}
|
||||
}
|
||||
|
||||
/* Call __wakeup() method on the object. */
|
||||
@@ -1034,14 +1038,22 @@ static void php_wddx_process_data(void *user_data, const XML_Char *s, int len)
|
||||
case ST_DATETIME: {
|
||||
char *tmp;
|
||||
|
||||
tmp = emalloc(len + 1);
|
||||
memcpy(tmp, (char *)s, len);
|
||||
if (Z_TYPE(ent->data) == IS_STRING) {
|
||||
tmp = safe_emalloc(Z_STRLEN(ent->data), 1, (size_t)len + 1);
|
||||
memcpy(tmp, Z_STRVAL(ent->data), Z_STRLEN(ent->data));
|
||||
memcpy(tmp + Z_STRLEN(ent->data), s, len);
|
||||
len += Z_STRLEN(ent->data);
|
||||
zval_dtor(&ent->data);
|
||||
} else {
|
||||
tmp = emalloc(len + 1);
|
||||
memcpy(tmp, (char *)s, len);
|
||||
}
|
||||
tmp[len] = '\0';
|
||||
|
||||
Z_LVAL(ent->data) = php_parse_date(tmp, NULL);
|
||||
ZVAL_LONG(&ent->data, php_parse_date(tmp, NULL));
|
||||
/* date out of range < 1969 or > 2038 */
|
||||
if (Z_LVAL(ent->data) == -1) {
|
||||
ZVAL_STRINGL(&ent->data, (char *)s, len);
|
||||
ZVAL_STRINGL(&ent->data, (char *)tmp, len);
|
||||
}
|
||||
efree(tmp);
|
||||
}
|
||||
@@ -1077,8 +1089,12 @@ int php_wddx_deserialize_ex(const char *value, size_t vallen, zval *return_value
|
||||
|
||||
if (stack.top == 1) {
|
||||
wddx_stack_top(&stack, (void**)&ent);
|
||||
ZVAL_COPY(return_value, &ent->data);
|
||||
retval = SUCCESS;
|
||||
if (Z_ISUNDEF(ent->data)) {
|
||||
retval = FAILURE;
|
||||
} else {
|
||||
ZVAL_COPY(return_value, &ent->data);
|
||||
retval = SUCCESS;
|
||||
}
|
||||
} else {
|
||||
retval = FAILURE;
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,6 +3,6 @@
|
||||
#define PHP_MAJOR_VERSION 7
|
||||
#define PHP_MINOR_VERSION 0
|
||||
#define PHP_RELEASE_VERSION 10
|
||||
#define PHP_EXTRA_VERSION "-dev"
|
||||
#define PHP_VERSION "7.0.10-dev"
|
||||
#define PHP_EXTRA_VERSION ""
|
||||
#define PHP_VERSION "7.0.10"
|
||||
#define PHP_VERSION_ID 70010
|
||||
@@ -3,7 +3,7 @@ cclient-2007f
|
||||
freetype-2.6.2
|
||||
icu-57.1
|
||||
jpeglib-9b
|
||||
libcurl-7.49.1
|
||||
libcurl-7.50.1
|
||||
libiconv-1.14
|
||||
libmcrypt-2.5.8
|
||||
libmpir-2.7.2
|
||||
|
||||
Reference in new issue
Block a user