mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-18 14:36:38 +00:00
Compare commits
151
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
032d23a94f | ||
|
|
9bda8eeb58 | ||
|
|
edfc1de7df | ||
|
|
1c23b0d39b | ||
|
|
66c3a174f5 | ||
|
|
fb86a176ba | ||
|
|
ead72aabfb | ||
|
|
6afbb74194 | ||
|
|
28e7addb9d | ||
|
|
f6c15e2caf | ||
|
|
23a3bbb468 | ||
|
|
ef3e0ee08a | ||
|
|
2558acbd66 | ||
|
|
04078a597c | ||
|
|
57918b1a1b | ||
|
|
8deadfa31b | ||
|
|
f95f8a3c1e | ||
|
|
178bbe3478 | ||
|
|
896e4d3428 | ||
|
|
125fc0b8d4 | ||
|
|
0cafd53d18 | ||
|
|
0328ff49cc | ||
|
|
42c72ef463 | ||
|
|
272df442f5 | ||
|
|
b8e49fe872 | ||
|
|
5acab7ebb4 | ||
|
|
67c4d1f5b9 | ||
|
|
c340f97ab0 | ||
|
|
c7387ab92f | ||
|
|
3f71ba2611 | ||
|
|
7f83976200 | ||
|
|
66308af539 | ||
|
|
98c8ad9218 | ||
|
|
20b62ade29 | ||
|
|
096f148c61 | ||
|
|
12e15be921 | ||
|
|
60a68a45c3 | ||
|
|
310c0561a9 | ||
|
|
568df31698 | ||
|
|
37962c61d2 | ||
|
|
2b3346208a | ||
|
|
1b88c85cd8 | ||
|
|
76637017ac | ||
|
|
9f7e8b777c | ||
|
|
c0ae3a7fb7 | ||
|
|
7f9183ce20 | ||
|
|
97f8ca52fa | ||
|
|
a2771296c0 | ||
|
|
39ddf6b89c | ||
|
|
054fad6d63 | ||
|
|
1fcea24efb | ||
|
|
263f14ac60 | ||
|
|
ea3c992bff | ||
|
|
0071c7ed7e | ||
|
|
c0b1bdcdc3 | ||
|
|
7c6cf09463 | ||
|
|
976e71a2fa | ||
|
|
5ccb5fd91e | ||
|
|
f99926f554 | ||
|
|
8e48895f48 | ||
|
|
d4f7e8cedc | ||
|
|
a1fdfa700b | ||
|
|
0a36d417e8 | ||
|
|
a04fac84e7 | ||
|
|
600402d986 | ||
|
|
340a06778c | ||
|
|
da3a807f22 | ||
|
|
454d297564 | ||
|
|
7a8ffcec7d | ||
|
|
29fa4d203a | ||
|
|
0826a54836 | ||
|
|
25f5a1b2e1 | ||
|
|
eebcfeb68e | ||
|
|
0a181ca27a | ||
|
|
9688071679 | ||
|
|
50f476591f | ||
|
|
39d8fc1edc | ||
|
|
206fd35a98 | ||
|
|
75cb678206 | ||
|
|
498eb8e052 | ||
|
|
688e56d0ac | ||
|
|
838951c2d6 | ||
|
|
bc7ea73da5 | ||
|
|
538f95b1b7 | ||
|
|
c483b59124 | ||
|
|
06bfada99b | ||
|
|
bccca0b53a | ||
|
|
4be867e910 | ||
|
|
a08847ab39 | ||
|
|
4adc08a403 | ||
|
|
5e4ee3d0bd | ||
|
|
eb1d1fe373 | ||
|
|
f448b0e6dd | ||
|
|
282355efd5 | ||
|
|
c93b461ad7 | ||
|
|
fc4cd598a2 | ||
|
|
703bbf5210 | ||
|
|
f901bec494 | ||
|
|
5787f91c55 | ||
|
|
8fc0bdfb0a | ||
|
|
797edd6211 | ||
|
|
e0e167e581 | ||
|
|
51e2015af3 | ||
|
|
71297a254b | ||
|
|
2c508c4d40 | ||
|
|
e857936518 | ||
|
|
988c3f9659 | ||
|
|
ae0585c98e | ||
|
|
a480bf8093 | ||
|
|
8309c04464 | ||
|
|
766f827e26 | ||
|
|
3ec37a74a2 | ||
|
|
78b0a85de6 | ||
|
|
67bb06cc9b | ||
|
|
729cd8bacd | ||
|
|
81396ea890 | ||
|
|
963e50c8c4 | ||
|
|
073b6ea818 | ||
|
|
d7c98ca1ac | ||
|
|
6dd85f83f7 | ||
|
|
84b6152842 | ||
|
|
9552cf6b84 | ||
|
|
2d858fbfb1 | ||
|
|
6d3d9104e6 | ||
|
|
7566742754 | ||
|
|
64b1085464 | ||
|
|
7b7d99839c | ||
|
|
3646604203 | ||
|
|
44a80b64b9 | ||
|
|
c34c523467 | ||
|
|
4f508003a9 | ||
|
|
03713ace23 | ||
|
|
ca7547c9e2 | ||
|
|
4ff2665509 | ||
|
|
3f8d21b922 | ||
|
|
8b7aaad7d6 | ||
|
|
958e3b93c3 | ||
|
|
06c9633b43 | ||
|
|
1bb2a4f91c | ||
|
|
3d09626f0d | ||
|
|
039ca4e219 | ||
|
|
8c04944b66 | ||
|
|
54fa0a69f8 | ||
|
|
51d76c346e | ||
|
|
675a9b2831 | ||
|
|
57257a4335 | ||
|
|
7e9479083d | ||
|
|
217b9e7b41 | ||
|
|
ab8177de2c | ||
|
|
86de4d7af6 | ||
|
|
3c939e3f69 |
No files matched your search
@@ -11,9 +11,7 @@ end
|
||||
|
||||
define ____executor_globals
|
||||
if basic_functions_module.zts
|
||||
if !$tsrm_ls
|
||||
set $tsrm_ls = ts_resource_ex(0, 0)
|
||||
end
|
||||
set $tsrm_ls = _tsrm_ls_cache
|
||||
set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1])
|
||||
set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
|
||||
set $eg_ptr = $eg
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--------------------------------------------------------------------
|
||||
The PHP License, version 3.01
|
||||
Copyright (c) 1999 - 2019 The PHP Group. All rights reserved.
|
||||
Copyright (c) 1999 - 2021 The PHP Group. All rights reserved.
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -1,20 +1,181 @@
|
||||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? 2021, PHP 7.4.16
|
||||
03 Jun 2021, PHP 7.4.20
|
||||
|
||||
- Core:
|
||||
. Fixed bug #80929 (Method name corruption related to repeated calls to
|
||||
call_user_func_array). (twosee)
|
||||
. Fixed bug #80960 (opendir() warning wrong info when failed on Windows).
|
||||
(cmb)
|
||||
. Fixed bug #67792 (HTTP Authorization schemes are treated as case-sensitive).
|
||||
(cmb)
|
||||
. Fixed bug #80972 (Memory exhaustion on invalid string offset). (girgias)
|
||||
|
||||
- FPM:
|
||||
. Fixed bug #65800 (Events port mechanism). (psumbera)
|
||||
|
||||
- FTP:
|
||||
. Fixed bug #80901 (Info leak in ftp extension). (cmb)
|
||||
. Fixed bug #79100 (Wrong FTP error messages). (cmb)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #81032 (GD install is affected by external libgd installation).
|
||||
(Flavio Heleno, cmb)
|
||||
|
||||
- MBString:
|
||||
. Fixed bug #81011 (mb_convert_encoding removes references from arrays). (cmb)
|
||||
|
||||
- ODBC:
|
||||
. Fixed bug #80460 (ODBC doesn't account for SQL_NO_TOTAL indicator). (cmb)
|
||||
|
||||
- PDO_MySQL:
|
||||
. Fixed bug #81037 (PDO discards error message text from prepared
|
||||
statement). (Kamil Tekiela)
|
||||
|
||||
- PDO_ODBC:
|
||||
. Fixed bug #44643 (bound parameters ignore explicit type definitions). (cmb)
|
||||
|
||||
- pgsql:
|
||||
. Fixed php_pgsql_fd_cast() wrt. php_stream_can_cast(). (cmb)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #80933 (SplFileObject::DROP_NEW_LINE is broken for NUL and CR).
|
||||
(cmb, Nikita)
|
||||
|
||||
- Opcache:
|
||||
. Fixed bug #80900 (switch statement behavior inside function). (twosee)
|
||||
. Fixed bug #81015 (Opcache optimization assumes wrong part of ternary
|
||||
operator in if-condition). (Nikita)
|
||||
|
||||
- XMLReader:
|
||||
. Fixed bug #73246 (XMLReader: encoding length not checked). (cmb)
|
||||
|
||||
- Zip:
|
||||
. Fixed bug #80863 (ZipArchive::extractTo() ignores references). (cmb)
|
||||
|
||||
06 May 2021, PHP 7.4.19
|
||||
|
||||
- PDO_pgsql:
|
||||
. Reverted bug fix for #80892 (PDO::PARAM_INT is treated the same as
|
||||
PDO::PARAM_STR). (Matteo)
|
||||
|
||||
|
||||
29 Apr 2021, PHP 7.4.18
|
||||
|
||||
- Core:
|
||||
. Fixed bug #80781 (Error handler that throws ErrorException infinite loop).
|
||||
(Nikita)
|
||||
. Fixed bug #75776 (Flushing streams with compression filter is broken). (cmb)
|
||||
|
||||
- Dba:
|
||||
. Fixed bug #80817 (dba_popen() may cause segfault during RSHUTDOWN). (cmb)
|
||||
|
||||
- DOM:
|
||||
. Fixed bug #66783 (UAF when appending DOMDocument to element). (cmb)
|
||||
|
||||
- FPM:
|
||||
. Fixed bug #80024 (Duplication of info about inherited socket after pool
|
||||
removing). (Jakub Zelenka)
|
||||
|
||||
- FTP:
|
||||
. Fixed bug #80880 (SSL_read on shutdown, ftp/proc_open). (cmb, Jakub
|
||||
Zelenka)
|
||||
|
||||
- Imap:
|
||||
. Fixed bug #80710 (imap_mail_compose() header injection). (cmb, Stas)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug #80763 (msgfmt_format() does not accept DateTime references).
|
||||
(cmb)
|
||||
|
||||
- LibXML:
|
||||
. Fixed bug #51903 (simplexml_load_file() doesn't use HTTP headers). (cmb)
|
||||
. Fixed bug #73533 (Invalid memory access in php_libxml_xmlCheckUTF8). (cmb)
|
||||
|
||||
- MySQLnd:
|
||||
. Fixed bug #80713 (SegFault when disabling ATTR_EMULATE_PREPARES and
|
||||
MySQL 8.0). (Nikita)
|
||||
. Fixed bug #80837 (Calling stmt_store_result after fetch doesn't throw an
|
||||
error). (Kamil Tekiela)
|
||||
|
||||
- Opcache:
|
||||
. Fixed bug #80805 (create simple class and get error in opcache.so). (Nikita)
|
||||
. Fixed bug #80950 (Variables become null in if statements). (Nikita)
|
||||
|
||||
- Pcntl:
|
||||
. Fixed bug #79812 (Potential integer overflow in pcntl_exec()). (cmb)
|
||||
|
||||
- PCRE:
|
||||
. Fixed bug #80866 (preg_split ignores limit flag when pattern with \K has
|
||||
0-width fullstring match). (Kamil Tekiela)
|
||||
|
||||
- PDO_ODBC:
|
||||
. Fixed bug #80783 (PDO ODBC truncates BLOB records at every 256th byte).
|
||||
(cmb)
|
||||
|
||||
- PDO_pgsql:
|
||||
. Fixed bug #80892 (PDO::PARAM_INT is treated the same as PDO::PARAM_STR).
|
||||
(Matteo)
|
||||
|
||||
- phpdbg:
|
||||
. Fixed bug #80757 (Exit code is 0 when could not open file). (Felipe)
|
||||
|
||||
- Session:
|
||||
. Fixed bug #80774 (session_name() problem with backslash). (cmb)
|
||||
. Fixed bug #80889 (Cannot set save handler when save_handler is invalid).
|
||||
(cmb)
|
||||
|
||||
- SOAP:
|
||||
. Fixed bug #69668 (SOAP special XML characters in namespace URIs not
|
||||
encoded). (cmb)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #78719 (http wrapper silently ignores long Location headers).
|
||||
(cmb)
|
||||
. Fixed bug #80771 (phpinfo(INFO_CREDITS) displays nothing in CLI). (cmb)
|
||||
. Fixed bug #80838 (HTTP wrapper waits for HTTP 1 response after HTTP 101).
|
||||
(manuelm)
|
||||
. Fixed bug #80915 (Taking a reference to $_SERVER hides its values from
|
||||
phpinfo()). (Rowan Tommins)
|
||||
|
||||
04 Mar 2021, php 7.4.16
|
||||
|
||||
- Core:
|
||||
. Fixed #80706 (mail(): Headers after Bcc headers may be ignored). (cmb)
|
||||
|
||||
- MySQLnd:
|
||||
. Fixed bug #78680 (mysqlnd's mysql_clear_password does not transmit
|
||||
null-terminated password). (Daniel Black)
|
||||
|
||||
- MySQLi:
|
||||
. Fixed bug #74779 (x() and y() truncating floats to integers). (cmb)
|
||||
|
||||
- OPcache:
|
||||
. Fixed bug #80682 (opcache doesn't honour pcre.jit option). (Remi)
|
||||
|
||||
- OpenSSL:
|
||||
. Fixed bug #80747 (Providing RSA key size < 512 generates key that crash
|
||||
PHP). (Nikita)
|
||||
|
||||
- Phar:
|
||||
. Fixed bug #75850 (Unclear error message wrt. __halt_compiler() w/o
|
||||
semicolon) (cmb)
|
||||
. Fixed bug #70091 (Phar does not mark UTF-8 filenames in ZIP archives). (cmb)
|
||||
. Fixed bug #53467 (Phar cannot compress large archives). (cmb, lserni)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug#80719 (Iterating after failed ArrayObject::setIteratorClass()
|
||||
causes Segmentation fault). (Nikita)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #80654 (file_get_contents() maxlen fails above (2**31)-1 bytes).
|
||||
(cmb)
|
||||
|
||||
- Zip:
|
||||
. Fixed bug #80648 (Fix for bug 79296 should be based on runtime version).
|
||||
(cmb, Remi)
|
||||
|
||||
21 Jan 2021, PHP 7.4.15
|
||||
04 Feb 2021, PHP 7.4.15
|
||||
|
||||
- Core:
|
||||
. Fixed bug #80523 (bogus parse error on >4GB source code). (Nikita)
|
||||
@@ -92,7 +253,7 @@ PHP NEWS
|
||||
PROCEDURE resultset SIGNAL). (Nikita)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #77423 (FILTER_VALIDATE_URL accepts URLs with invalid userinfo).
|
||||
. Fixed bug #77423 (FILTER_VALIDATE_URL accepts URLs with invalid userinfo).
|
||||
(CVE-2020-7071) (cmb)
|
||||
. Fixed bug #80366 (Return Value of zend_fstat() not Checked). (sagpant, cmb)
|
||||
. Fixed bug #80411 (References to null-serialized object break serialize()).
|
||||
@@ -231,7 +392,7 @@ PHP NEWS
|
||||
. Fixed bug #80048 (Bug #69100 has not been fixed for Windows). (cmb)
|
||||
. Fixed bug #80049 (Memleak when coercing integers to string via variadic
|
||||
argument). (Nikita)
|
||||
. Fixed bug #79699 (PHP parses encoded cookie names so malicious `__Host-`
|
||||
. Fixed bug #79699 (PHP parses encoded cookie names so malicious `__Host-`
|
||||
cookies can be sent). (CVE-2020-7070) (Stas)
|
||||
|
||||
- Calendar:
|
||||
@@ -250,7 +411,7 @@ PHP NEWS
|
||||
handlers changed). (SammyK)
|
||||
|
||||
- OpenSSL:
|
||||
. Fixed bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12
|
||||
. Fixed bug #79601 (Wrong ciphertext/tag in AES-CCM encryption for a 12
|
||||
bytes IV). (CVE-2020-7069) (Jakub Zelenka)
|
||||
|
||||
- PDO:
|
||||
@@ -332,7 +493,7 @@ PHP NEWS
|
||||
(cmb)
|
||||
|
||||
- Core:
|
||||
. Fixed bug #79877 (getimagesize function silently truncates after a null
|
||||
. Fixed bug #79877 (getimagesize function silently truncates after a null
|
||||
byte) (cmb)
|
||||
. Fixed bug #79740 (serialize() and unserialize() methods can not be called
|
||||
statically). (Nikita)
|
||||
@@ -393,7 +554,7 @@ PHP NEWS
|
||||
. Fixed possibly unsupported timercmp() usage. (cmb)
|
||||
|
||||
- Exif:
|
||||
. Fixed bug #79687 (Sony picture - PHP Warning - Make, Model, MakerNotes).
|
||||
. Fixed bug #79687 (Sony picture - PHP Warning - Make, Model, MakerNotes).
|
||||
(cmb)
|
||||
|
||||
- Fileinfo:
|
||||
@@ -609,7 +770,7 @@ PHP NEWS
|
||||
. Fixed bug #79014 (PHP-FPM & Primary script unknown). (Jakub Zelenka)
|
||||
|
||||
- MBstring:
|
||||
. Fixed bug #79371 (mb_strtolower (UTF-32LE): stack-buffer-overflow at
|
||||
. Fixed bug #79371 (mb_strtolower (UTF-32LE): stack-buffer-overflow at
|
||||
php_unicode_tolower_full). (CVE-2020-7065) (cmb)
|
||||
|
||||
- MySQLi:
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
HT iterator should be destroyed if array becomes empty during array_splice
|
||||
--FILE--
|
||||
<?php
|
||||
$a=[4];
|
||||
$i = 0;
|
||||
foreach ($a as &$r) {
|
||||
var_dump($r);
|
||||
$a = array_splice($a, 0);
|
||||
if (++$i == 2) break;
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
int(4)
|
||||
int(4)
|
||||
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
Bug #80781: Error handler that throws ErrorException infinite loop
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function handle(int $severity, string $message, string $file, int $line): bool {
|
||||
if((error_reporting() & $severity) !== 0) {
|
||||
throw new \ErrorException($message, 0, $severity, $file, $line);
|
||||
}
|
||||
|
||||
return true; // stfu operator
|
||||
}
|
||||
|
||||
set_error_handler('handle');
|
||||
|
||||
function getPlugin(string $plugin) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$array = [];
|
||||
if (isset($array[$data]) or getPlugin($data)) {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught ErrorException: Illegal offset type in isset or empty in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): handle(2, 'Illegal offset ...', %s, %d, Array)
|
||||
#1 {main}
|
||||
thrown in %s on line %d
|
||||
@@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
Bug #80972: Memory exhaustion on invalid string offset
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function exceptions_error_handler($severity, $message, $filename, $lineno) {
|
||||
if (error_reporting() & $severity) {
|
||||
throw new ErrorException($message, 0, $severity, $filename, $lineno);
|
||||
}
|
||||
}
|
||||
set_error_handler('exceptions_error_handler');
|
||||
|
||||
$float = 10e120;
|
||||
$string_float = (string) $float;
|
||||
|
||||
$string = 'Here is some text for good measure';
|
||||
|
||||
try {
|
||||
echo 'Float casted to string compile', \PHP_EOL;
|
||||
$string[(string) 10e120] = 'E';
|
||||
var_dump($string);
|
||||
} catch (\Throwable $e) {
|
||||
echo $e->getMessage(), \PHP_EOL;
|
||||
}
|
||||
|
||||
/* This same bug also permits to modify the first byte of a string even if
|
||||
* the offset is invalid */
|
||||
try {
|
||||
/* This must not affect the string value */
|
||||
$string["wrong"] = "f";
|
||||
} catch (\Throwable $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
var_dump($string);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Float casted to string compile
|
||||
Illegal string offset '1.0E+121'
|
||||
Illegal string offset 'wrong'
|
||||
string(34) "Here is some text for good measure"
|
||||
@@ -0,0 +1,56 @@
|
||||
--TEST--
|
||||
Bug #80929: Method name corruption related to zend_closure_call_magic
|
||||
--FILE--
|
||||
<?php
|
||||
class DefaultListener
|
||||
{
|
||||
public function handleDefaultEvent($event) { }
|
||||
}
|
||||
|
||||
class SubscriberProxy
|
||||
{
|
||||
private array $subscribedEvents;
|
||||
private object $subscriber;
|
||||
private Closure $listener;
|
||||
|
||||
public function __construct(array $subscribedEvents, object $subscriber)
|
||||
{
|
||||
$this->subscribedEvents = $subscribedEvents;
|
||||
$this->subscriber = $subscriber;
|
||||
foreach ($this->subscribedEvents as $eventName => $params) {
|
||||
$this->listener = Closure::fromCallable([$this, $params]);
|
||||
}
|
||||
}
|
||||
|
||||
public function __call(string $name, array $arguments)
|
||||
{
|
||||
return $this->subscriber->$name(...$arguments);
|
||||
}
|
||||
|
||||
public function dispatch($event, string $eventName)
|
||||
{
|
||||
($this->listener)($event, $eventName, null);
|
||||
}
|
||||
}
|
||||
|
||||
$proxy = new SubscriberProxy(
|
||||
['defaultEvent' => 'handleDefaultEvent'],
|
||||
new DefaultListener()
|
||||
);
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
echo $i . PHP_EOL;
|
||||
$proxy->dispatch(null, 'defaultEvent');
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
Symtable cache slots may be acquired while cleaning symtable
|
||||
--FILE--
|
||||
<?php
|
||||
class A {
|
||||
// Must be larger than the symtable cache.
|
||||
static $max = 40;
|
||||
function __destruct() {
|
||||
if (self::$max-- < 0) return;
|
||||
$x = 'y';
|
||||
$$x = new a;
|
||||
}
|
||||
}
|
||||
new A;
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
===DONE===
|
||||
+1
-1
@@ -1099,7 +1099,7 @@ static zend_always_inline void zend_mm_free_pages_ex(zend_mm_heap *heap, zend_mm
|
||||
/* this setting may be not accurate */
|
||||
chunk->free_tail = page_num;
|
||||
}
|
||||
if (free_chunk && chunk->free_pages == ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE) {
|
||||
if (free_chunk && chunk != heap->main_chunk && chunk->free_pages == ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE) {
|
||||
zend_mm_delete_chunk(heap, chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +270,6 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ {
|
||||
|
||||
zend_call_function(&fci, &fcc);
|
||||
|
||||
zval_ptr_dtor(&fci.params[0]);
|
||||
zval_ptr_dtor(&fci.params[1]);
|
||||
}
|
||||
/* }}} */
|
||||
@@ -473,6 +472,8 @@ static void zend_closure_free_storage(zend_object *object) /* {{{ */
|
||||
|
||||
if (closure->func.type == ZEND_USER_FUNCTION) {
|
||||
destroy_op_array(&closure->func.op_array);
|
||||
} else if (closure->orig_internal_handler == zend_closure_call_magic) {
|
||||
zend_string_release(closure->func.common.function_name);
|
||||
}
|
||||
|
||||
if (Z_TYPE(closure->this_ptr) != IS_UNDEF) {
|
||||
|
||||
+15
-7
@@ -51,11 +51,11 @@
|
||||
# define ZEND_VM_FP_GLOBAL_REG "%r14"
|
||||
# define ZEND_VM_IP_GLOBAL_REG "%r15"
|
||||
# elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__powerpc64__)
|
||||
# define ZEND_VM_FP_GLOBAL_REG "r28"
|
||||
# define ZEND_VM_IP_GLOBAL_REG "r29"
|
||||
# define ZEND_VM_FP_GLOBAL_REG "r14"
|
||||
# define ZEND_VM_IP_GLOBAL_REG "r15"
|
||||
# elif defined(__IBMC__) && ZEND_GCC_VERSION >= 4002 && defined(__powerpc64__)
|
||||
# define ZEND_VM_FP_GLOBAL_REG "r28"
|
||||
# define ZEND_VM_IP_GLOBAL_REG "r29"
|
||||
# define ZEND_VM_FP_GLOBAL_REG "r14"
|
||||
# define ZEND_VM_IP_GLOBAL_REG "r15"
|
||||
# elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__aarch64__)
|
||||
# define ZEND_VM_FP_GLOBAL_REG "x27"
|
||||
# define ZEND_VM_IP_GLOBAL_REG "x28"
|
||||
@@ -1550,6 +1550,12 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
|
||||
zend_long offset;
|
||||
|
||||
offset = zend_check_string_offset(dim, BP_VAR_W EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception) != NULL)) {
|
||||
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
|
||||
ZVAL_UNDEF(EX_VAR(opline->result.var));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (offset < -(zend_long)Z_STRLEN_P(str)) {
|
||||
/* Error on negative offset */
|
||||
zend_error(E_WARNING, "Illegal string offset: " ZEND_LONG_FMT, offset);
|
||||
@@ -3437,12 +3443,13 @@ ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_val
|
||||
|
||||
ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table) /* {{{ */
|
||||
{
|
||||
/* Clean before putting into the cache, since clean could call dtors,
|
||||
* which could use the cached hash. Also do this before the check for
|
||||
* available cache slots, as those may be used by a dtor as well. */
|
||||
zend_symtable_clean(symbol_table);
|
||||
if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
|
||||
zend_array_destroy(symbol_table);
|
||||
} else {
|
||||
/* clean before putting into the cache, since clean
|
||||
could call dtors, which could use cached hash */
|
||||
zend_symtable_clean(symbol_table);
|
||||
*(EG(symtable_cache_ptr)++) = symbol_table;
|
||||
}
|
||||
}
|
||||
@@ -4554,6 +4561,7 @@ static zend_always_inline zend_execute_data *_zend_vm_stack_push_call_frame(uint
|
||||
if (check_exception) { \
|
||||
OPLINE = EX(opline) + (skip); \
|
||||
} else { \
|
||||
ZEND_ASSERT(!EG(exception)); \
|
||||
OPLINE = opline + (skip); \
|
||||
} \
|
||||
ZEND_VM_CONTINUE()
|
||||
|
||||
+1
-1
@@ -1630,10 +1630,10 @@ ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
|
||||
} else if (EXPECTED(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED)) {
|
||||
goto free_ht;
|
||||
}
|
||||
zend_hash_iterators_remove(ht);
|
||||
SET_INCONSISTENT(HT_DESTROYED);
|
||||
efree(HT_GET_DATA_ADDR(ht));
|
||||
free_ht:
|
||||
zend_hash_iterators_remove(ht);
|
||||
FREE_HASHTABLE(ht);
|
||||
}
|
||||
|
||||
|
||||
@@ -1067,6 +1067,11 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
}
|
||||
#endif
|
||||
if (path_length + state_cwd_length + 1 >= MAXPATHLEN-1) {
|
||||
#ifdef ZEND_WIN32
|
||||
SET_ERRNO_FROM_WIN32_CODE(ERROR_BUFFER_OVERFLOW);
|
||||
#else
|
||||
errno = ENAMETOOLONG;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
memcpy(resolved_path, state->cwd, state_cwd_length);
|
||||
@@ -1095,6 +1100,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
|
||||
#ifdef ZEND_WIN32
|
||||
if (memchr(resolved_path, '*', path_length) ||
|
||||
memchr(resolved_path, '?', path_length)) {
|
||||
SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_NAME);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6937,6 +6937,10 @@ ZEND_VM_C_LABEL(num_index_prop):
|
||||
ZEND_VM_C_GOTO(isset_again);
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
ZEND_VM_C_GOTO(isset_dim_obj_exit);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
|
||||
@@ -6302,6 +6302,10 @@ num_index_prop:
|
||||
goto isset_again;
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
goto isset_dim_obj_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
@@ -8496,6 +8500,10 @@ num_index_prop:
|
||||
goto isset_again;
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
goto isset_dim_obj_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
@@ -10949,6 +10957,10 @@ num_index_prop:
|
||||
goto isset_again;
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
goto isset_dim_obj_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
@@ -14985,6 +14997,10 @@ num_index_prop:
|
||||
goto isset_again;
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
goto isset_dim_obj_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
@@ -16402,6 +16418,10 @@ num_index_prop:
|
||||
goto isset_again;
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
goto isset_dim_obj_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
@@ -17689,6 +17709,10 @@ num_index_prop:
|
||||
goto isset_again;
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
goto isset_dim_obj_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
@@ -41505,6 +41529,10 @@ num_index_prop:
|
||||
goto isset_again;
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
goto isset_dim_obj_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
@@ -44950,6 +44978,10 @@ num_index_prop:
|
||||
goto isset_again;
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
goto isset_dim_obj_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
@@ -50123,6 +50155,10 @@ num_index_prop:
|
||||
goto isset_again;
|
||||
} else {
|
||||
value = zend_find_array_dim_slow(ht, offset EXECUTE_DATA_CC);
|
||||
if (UNEXPECTED(EG(exception))) {
|
||||
result = 0;
|
||||
goto isset_dim_obj_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(opline->extended_value & ZEND_ISEMPTY)) {
|
||||
|
||||
@@ -104,6 +104,6 @@ nmake test TESTS="%OPCACHE_OPTS% -q --offline --show-diff --show-slow 1000 --set
|
||||
|
||||
set EXIT_CODE=%errorlevel%
|
||||
|
||||
powershell -Command "$wc = New-Object 'System.Net.WebClient'; $wc.UploadFile('https://ci.appveyor.com/api/testresults/junit/%APPVEYOR_JOB_ID%', 'c:\junit.out.xml')"
|
||||
appveyor PushArtifact %TEST_PHP_JUNIT%
|
||||
|
||||
exit /b %EXIT_CODE%
|
||||
@@ -4,6 +4,9 @@ parameters:
|
||||
steps:
|
||||
- script: |
|
||||
sudo apt-get update -y | true
|
||||
# There appears to be some kind of conflict with the libzip from ondrej's PPA.
|
||||
# Purge existing libzip and let it be reinstalled to avoid it.
|
||||
sudo apt-get purge -y libzip4
|
||||
sudo apt install bison \
|
||||
re2c \
|
||||
locales \
|
||||
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
- script: |
|
||||
git clone https://github.com/laravel/framework.git --branch=master --depth=1
|
||||
cd framework
|
||||
php7.3 /usr/bin/composer install --no-progress
|
||||
php7.4 /usr/bin/composer install --no-progress
|
||||
export USE_ZEND_ALLOC=0
|
||||
sed -i 's/$exit = true/$exit = false/g' vendor/phpunit/phpunit/src/TextUI/Command.php
|
||||
# Avoid test using exit(), which thus leaks.
|
||||
@@ -61,8 +61,8 @@ jobs:
|
||||
- script: |
|
||||
git clone https://github.com/symfony/symfony.git --depth=1
|
||||
cd symfony
|
||||
php7.3 /usr/bin/composer install --no-progress
|
||||
php7.3 ./phpunit install
|
||||
php7.4 /usr/bin/composer install --no-progress
|
||||
php7.4 ./phpunit install
|
||||
export USE_ZEND_ALLOC=0
|
||||
export USE_TRACKED_ALLOC=1
|
||||
export ASAN_OPTIONS=exitcode=139
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
displayName: 'Test Amphp'
|
||||
condition: or(succeeded(), failed())
|
||||
- script: |
|
||||
php7.3 /usr/bin/composer create-project symfony/symfony-demo symfony_demo --no-progress
|
||||
php7.4 /usr/bin/composer create-project symfony/symfony-demo symfony_demo --no-progress
|
||||
cd symfony_demo
|
||||
export USE_ZEND_ALLOC=0
|
||||
export USE_TRACKED_ALLOC=1
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ parameters:
|
||||
jobs:
|
||||
- job: ${{ parameters.configurationName }}
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
vmImage: 'ubuntu-20.04'
|
||||
steps:
|
||||
- template: apt.yml
|
||||
- script: |
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ dnl Basic autoconf initialization, generation of config.nice.
|
||||
dnl ----------------------------------------------------------------------------
|
||||
|
||||
AC_PREREQ([2.68])
|
||||
AC_INIT([PHP],[7.4.16-dev],[https://bugs.php.net],[php],[https://www.php.net])
|
||||
AC_INIT([PHP],[7.4.20],[https://bugs.php.net],[php],[https://www.php.net])
|
||||
AC_CONFIG_SRCDIR([main/php_version.h])
|
||||
AC_CONFIG_AUX_DIR([build])
|
||||
AC_PRESERVE_HELP_ORDER
|
||||
@@ -568,7 +568,7 @@ dnl Fix for these systems is already included in GCC 7, but not on GCC 6.
|
||||
dnl
|
||||
dnl At least some versions of FreeBSD seem to have buggy ifunc support, see
|
||||
dnl bug #77284. Conservatively don't use ifuncs on FreeBSD.
|
||||
AS_CASE([$host_alias], [*-*-*android*|*-*-*uclibc*|*-*-*musl*|*freebsd*], [true], [
|
||||
AS_CASE([$host_alias], [*-*-*android*|*-*-*uclibc*|*-*-*musl*|*freebsd*|*openbsd*], [true], [
|
||||
AX_GCC_FUNC_ATTRIBUTE([ifunc])
|
||||
AX_GCC_FUNC_ATTRIBUTE([target])
|
||||
])
|
||||
|
||||
+10
-3
@@ -41,6 +41,7 @@ typedef struct _php_bz2_filter_data {
|
||||
enum strm_status status; /* Decompress option */
|
||||
unsigned int small_footprint : 1; /* Decompress option */
|
||||
unsigned int expect_concatenated : 1; /* Decompress option */
|
||||
unsigned int is_flushed : 1; /* only for compression */
|
||||
|
||||
int persistent;
|
||||
} php_bz2_filter_data;
|
||||
@@ -228,6 +229,8 @@ static php_stream_filter_status_t php_bz2_compress_filter(
|
||||
bucket = php_stream_bucket_make_writeable(buckets_in->head);
|
||||
|
||||
while (bin < bucket->buflen) {
|
||||
int flush_mode;
|
||||
|
||||
desired = bucket->buflen - bin;
|
||||
if (desired > data->inbuf_len) {
|
||||
desired = data->inbuf_len;
|
||||
@@ -235,7 +238,9 @@ static php_stream_filter_status_t php_bz2_compress_filter(
|
||||
memcpy(data->strm.next_in, bucket->buf + bin, desired);
|
||||
data->strm.avail_in = desired;
|
||||
|
||||
status = BZ2_bzCompress(&(data->strm), flags & PSFS_FLAG_FLUSH_CLOSE ? BZ_FINISH : (flags & PSFS_FLAG_FLUSH_INC ? BZ_FLUSH : BZ_RUN));
|
||||
flush_mode = flags & PSFS_FLAG_FLUSH_CLOSE ? BZ_FINISH : (flags & PSFS_FLAG_FLUSH_INC ? BZ_FLUSH : BZ_RUN);
|
||||
data->is_flushed = flush_mode != BZ_RUN;
|
||||
status = BZ2_bzCompress(&(data->strm), flush_mode);
|
||||
if (status != BZ_RUN_OK && status != BZ_FLUSH_OK && status != BZ_FINISH_OK) {
|
||||
/* Something bad happened */
|
||||
php_stream_bucket_delref(bucket);
|
||||
@@ -261,11 +266,12 @@ static php_stream_filter_status_t php_bz2_compress_filter(
|
||||
php_stream_bucket_delref(bucket);
|
||||
}
|
||||
|
||||
if (flags & PSFS_FLAG_FLUSH_CLOSE) {
|
||||
if (flags & PSFS_FLAG_FLUSH_CLOSE || ((flags & PSFS_FLAG_FLUSH_INC) && !data->is_flushed)) {
|
||||
/* Spit it out! */
|
||||
status = BZ_FINISH_OK;
|
||||
while (status == BZ_FINISH_OK) {
|
||||
status = BZ2_bzCompress(&(data->strm), BZ_FINISH);
|
||||
status = BZ2_bzCompress(&(data->strm), (flags & PSFS_FLAG_FLUSH_CLOSE ? BZ_FINISH : BZ_FLUSH));
|
||||
data->is_flushed = 1;
|
||||
if (data->strm.avail_out < data->outbuf_len) {
|
||||
size_t bucketlen = data->outbuf_len - data->strm.avail_out;
|
||||
|
||||
@@ -381,6 +387,7 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi
|
||||
}
|
||||
|
||||
status = BZ2_bzCompressInit(&(data->strm), blockSize100k, 0, workFactor);
|
||||
data->is_flushed = 1;
|
||||
fops = &php_bz2_compress_ops;
|
||||
} else {
|
||||
status = BZ_DATA_ERROR;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
Bug #75776 (Flushing streams with compression filter is broken)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('bz2')) die('skip bz2 extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$text = str_repeat('0123456789abcdef', 1000);
|
||||
|
||||
$temp = fopen('php://temp', 'r+');
|
||||
stream_filter_append($temp, 'bzip2.compress', STREAM_FILTER_WRITE);
|
||||
fwrite($temp, $text);
|
||||
|
||||
rewind($temp);
|
||||
|
||||
var_dump(bin2hex(stream_get_contents($temp)));
|
||||
var_dump(ftell($temp));
|
||||
|
||||
fclose($temp);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(144) "425a68343141592653599fe7bbbf0001f389007fe03f002000902980026826aa80003ea9061520c6a41954833a9069520d6a41b54837a9071520e6a41d5483ba9079520f6a41f548"
|
||||
int(72)
|
||||
@@ -2207,6 +2207,7 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
|
||||
#endif
|
||||
|
||||
prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv);
|
||||
ZVAL_DEREF(prop);
|
||||
if (Z_TYPE_P(prop) != IS_STRING) {
|
||||
php_error_docref(NULL, E_WARNING, "Invalid filename for key %s", ZSTR_VAL(string_key));
|
||||
} else {
|
||||
@@ -2217,10 +2218,12 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
|
||||
}
|
||||
|
||||
prop = zend_read_property(curl_CURLFile_class, current, "mime", sizeof("mime")-1, 0, &rv);
|
||||
ZVAL_DEREF(prop);
|
||||
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
|
||||
type = Z_STRVAL_P(prop);
|
||||
}
|
||||
prop = zend_read_property(curl_CURLFile_class, current, "postname", sizeof("postname")-1, 0, &rv);
|
||||
ZVAL_DEREF(prop);
|
||||
if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) {
|
||||
filename = Z_STRVAL_P(prop);
|
||||
}
|
||||
|
||||
+2
-2
@@ -972,9 +972,9 @@ restart:
|
||||
zend_bool close_both;
|
||||
|
||||
close_both = (info->fp != info->lock.fp);
|
||||
php_stream_close(info->lock.fp);
|
||||
php_stream_free(info->lock.fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE);
|
||||
if (close_both) {
|
||||
php_stream_close(info->fp);
|
||||
php_stream_free(info->fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE);
|
||||
}
|
||||
info->fp = NULL;
|
||||
info->lock.fp = NULL;
|
||||
|
||||
+7
-3
@@ -1302,9 +1302,13 @@ int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child)
|
||||
{
|
||||
xmlNodePtr nodep;
|
||||
|
||||
if (parent == NULL || child == NULL || child->doc != parent->doc) {
|
||||
return SUCCESS;
|
||||
}
|
||||
if (parent == NULL || child == NULL || child->doc != parent->doc) {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
if (child->type == XML_DOCUMENT_NODE) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
nodep = parent;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ require_once __DIR__ .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = __DIR__."/tmp_savehtmlfile".time().".html";
|
||||
$filename = __DIR__."/DOMDocument_saveHTMLFile_basic.html";
|
||||
$doc = new DOMDocument('1.0');
|
||||
$root = $doc->createElement('html');
|
||||
$root = $doc->appendChild($root);
|
||||
|
||||
@@ -9,7 +9,7 @@ require_once __DIR__ .'/skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = __DIR__."/tmp_savehtmlfile".time().".html";
|
||||
$filename = __DIR__."/DOMDocument_saveHTMLFile_formatOutput.html";
|
||||
$doc = new DOMDocument('1.0');
|
||||
$doc->formatOutput = true;
|
||||
$root = $doc->createElement('html');
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
Bug #66783 (UAF when appending DOMDocument to element)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('dom')) die('skip dom extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$doc = new DomDocument;
|
||||
$doc->loadXML('<root></root>');
|
||||
$e = $doc->createElement('e');
|
||||
try {
|
||||
$e->appendChild($doc);
|
||||
} catch (DOMException $ex) {
|
||||
echo $ex->getMessage(), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Hierarchy Request Error
|
||||
+35
-22
@@ -63,6 +63,11 @@
|
||||
#include "ftp.h"
|
||||
#include "ext/standard/fsock.h"
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
# undef ETIMEDOUT
|
||||
# define ETIMEDOUT WSAETIMEDOUT
|
||||
#endif
|
||||
|
||||
/* sends an ftp command, returns true on success, false on error.
|
||||
* it sends the string "cmd args\r\n" if args is non-null, or
|
||||
* "cmd\r\n" if args is null
|
||||
@@ -1295,7 +1300,8 @@ ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const size_t cmd_len, const char *arg
|
||||
|
||||
data = ftp->outbuf;
|
||||
|
||||
/* Clear the extra-lines buffer */
|
||||
/* Clear the inbuf and extra-lines buffer */
|
||||
ftp->inbuf[0] = '\0';
|
||||
ftp->extra = NULL;
|
||||
|
||||
if (my_send(ftp, ftp->fd, data, size) != size) {
|
||||
@@ -1349,10 +1355,12 @@ ftp_readline(ftpbuf_t *ftp)
|
||||
|
||||
data = eol;
|
||||
if ((rcvd = my_recv(ftp, ftp->fd, data, size)) < 1) {
|
||||
*data = 0;
|
||||
return 0;
|
||||
}
|
||||
} while (size);
|
||||
|
||||
*data = 0;
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -1466,15 +1474,15 @@ my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
|
||||
n = php_pollfd_for_ms(s, POLLOUT, ftp->timeout_sec * 1000);
|
||||
|
||||
if (n < 1) {
|
||||
char buf[256];
|
||||
if (n == 0) {
|
||||
#ifdef PHP_WIN32
|
||||
if (n == 0) {
|
||||
_set_errno(ETIMEDOUT);
|
||||
}
|
||||
#else
|
||||
if (n == 0) {
|
||||
errno = ETIMEDOUT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
php_error_docref(NULL, E_WARNING, "%s", php_socket_strerror(errno, buf, sizeof buf));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1503,18 +1511,17 @@ my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
|
||||
SSL *handle = NULL;
|
||||
php_socket_t fd;
|
||||
#endif
|
||||
|
||||
n = php_pollfd_for_ms(s, PHP_POLLREADABLE, ftp->timeout_sec * 1000);
|
||||
if (n < 1) {
|
||||
char buf[256];
|
||||
if (n == 0) {
|
||||
#ifdef PHP_WIN32
|
||||
if (n == 0) {
|
||||
_set_errno(ETIMEDOUT);
|
||||
}
|
||||
#else
|
||||
if (n == 0) {
|
||||
errno = ETIMEDOUT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
php_error_docref(NULL, E_WARNING, "%s", php_socket_strerror(errno, buf, sizeof buf));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1581,15 +1588,15 @@ data_available(ftpbuf_t *ftp, php_socket_t s)
|
||||
|
||||
n = php_pollfd_for_ms(s, PHP_POLLREADABLE, 1000);
|
||||
if (n < 1) {
|
||||
char buf[256];
|
||||
if (n == 0) {
|
||||
#ifdef PHP_WIN32
|
||||
if (n == 0) {
|
||||
_set_errno(ETIMEDOUT);
|
||||
}
|
||||
#else
|
||||
if (n == 0) {
|
||||
errno = ETIMEDOUT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
php_error_docref(NULL, E_WARNING, "%s", php_socket_strerror(errno, buf, sizeof buf));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1605,15 +1612,15 @@ data_writeable(ftpbuf_t *ftp, php_socket_t s)
|
||||
|
||||
n = php_pollfd_for_ms(s, POLLOUT, 1000);
|
||||
if (n < 1) {
|
||||
char buf[256];
|
||||
if (n == 0) {
|
||||
#ifdef PHP_WIN32
|
||||
if (n == 0) {
|
||||
_set_errno(ETIMEDOUT);
|
||||
}
|
||||
#else
|
||||
if (n == 0) {
|
||||
errno = ETIMEDOUT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
php_error_docref(NULL, E_WARNING, "%s", php_socket_strerror(errno, buf, sizeof buf));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1630,15 +1637,15 @@ my_accept(ftpbuf_t *ftp, php_socket_t s, struct sockaddr *addr, socklen_t *addrl
|
||||
|
||||
n = php_pollfd_for_ms(s, PHP_POLLREADABLE, ftp->timeout_sec * 1000);
|
||||
if (n < 1) {
|
||||
char buf[256];
|
||||
if (n == 0) {
|
||||
#ifdef PHP_WIN32
|
||||
if (n == 0) {
|
||||
_set_errno(ETIMEDOUT);
|
||||
}
|
||||
#else
|
||||
if (n == 0) {
|
||||
errno = ETIMEDOUT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
php_error_docref(NULL, E_WARNING, "%s", php_socket_strerror(errno, buf, sizeof buf));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1931,6 +1938,12 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
|
||||
/* SSL wants a write. Really odd. Let's bail out. */
|
||||
done = 1;
|
||||
break;
|
||||
case SSL_ERROR_SYSCALL:
|
||||
/* most likely the peer closed the connection without
|
||||
sending a close_notify shutdown alert;
|
||||
bail out to avoid raising a spurious warning */
|
||||
done = 1;
|
||||
break;
|
||||
default:
|
||||
if ((sslerror = ERR_get_error())) {
|
||||
ERR_error_string_n(sslerror, buf, sizeof(buf));
|
||||
|
||||
+60
-20
@@ -455,7 +455,9 @@ PHP_FUNCTION(ftp_login)
|
||||
|
||||
/* log in */
|
||||
if (!ftp_login(ftp, user, user_len, pass, pass_len)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -480,7 +482,9 @@ PHP_FUNCTION(ftp_pwd)
|
||||
}
|
||||
|
||||
if (!(pwd = ftp_pwd(ftp))) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -504,7 +508,9 @@ PHP_FUNCTION(ftp_cdup)
|
||||
}
|
||||
|
||||
if (!ftp_cdup(ftp)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -531,7 +537,9 @@ PHP_FUNCTION(ftp_chdir)
|
||||
|
||||
/* change directories */
|
||||
if (!ftp_chdir(ftp, dir, dir_len)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -558,7 +566,9 @@ PHP_FUNCTION(ftp_exec)
|
||||
|
||||
/* execute serverside command */
|
||||
if (!ftp_exec(ftp, cmd, cmd_len)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -608,7 +618,9 @@ PHP_FUNCTION(ftp_mkdir)
|
||||
|
||||
/* create directory */
|
||||
if (NULL == (tmp = ftp_mkdir(ftp, dir, dir_len))) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -635,7 +647,9 @@ PHP_FUNCTION(ftp_rmdir)
|
||||
|
||||
/* remove directorie */
|
||||
if (!ftp_rmdir(ftp, dir, dir_len)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -662,7 +676,9 @@ PHP_FUNCTION(ftp_chmod)
|
||||
}
|
||||
|
||||
if (!ftp_chmod(ftp, mode, filename, filename_len)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -816,7 +832,9 @@ PHP_FUNCTION(ftp_systype)
|
||||
}
|
||||
|
||||
if (NULL == (syst = ftp_syst(ftp))) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -862,7 +880,9 @@ PHP_FUNCTION(ftp_fget)
|
||||
}
|
||||
|
||||
if (!ftp_get(ftp, stream, file, file_len, xtype, resumepos)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -912,7 +932,9 @@ PHP_FUNCTION(ftp_nb_fget)
|
||||
ftp->closestream = 0; /* do not close */
|
||||
|
||||
if ((ret = ftp_nb_get(ftp, stream, file, file_len, xtype, resumepos)) == PHP_FTP_FAILED) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_LONG(ret);
|
||||
}
|
||||
|
||||
@@ -1000,7 +1022,9 @@ PHP_FUNCTION(ftp_get)
|
||||
if (!ftp_get(ftp, outstream, remote, remote_len, xtype, resumepos)) {
|
||||
php_stream_close(outstream);
|
||||
VCWD_UNLINK(local);
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -1069,7 +1093,9 @@ PHP_FUNCTION(ftp_nb_get)
|
||||
php_stream_close(outstream);
|
||||
ftp->stream = NULL;
|
||||
VCWD_UNLINK(local);
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_LONG(PHP_FTP_FAILED);
|
||||
}
|
||||
|
||||
@@ -1163,7 +1189,9 @@ PHP_FUNCTION(ftp_fput)
|
||||
}
|
||||
|
||||
if (!ftp_put(ftp, remote, remote_len, stream, xtype, startpos)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -1217,7 +1245,9 @@ PHP_FUNCTION(ftp_nb_fput)
|
||||
ftp->closestream = 0; /* do not close */
|
||||
|
||||
if (((ret = ftp_nb_put(ftp, remote, remote_len, stream, xtype, startpos)) == PHP_FTP_FAILED)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_LONG(ret);
|
||||
}
|
||||
|
||||
@@ -1271,7 +1301,9 @@ PHP_FUNCTION(ftp_put)
|
||||
|
||||
if (!ftp_put(ftp, remote, remote_len, instream, xtype, startpos)) {
|
||||
php_stream_close(instream);
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
php_stream_close(instream);
|
||||
@@ -1307,7 +1339,9 @@ PHP_FUNCTION(ftp_append)
|
||||
|
||||
if (!ftp_append(ftp, remote, remote_len, instream, xtype)) {
|
||||
php_stream_close(instream);
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
php_stream_close(instream);
|
||||
@@ -1441,7 +1475,9 @@ PHP_FUNCTION(ftp_rename)
|
||||
|
||||
/* rename the file */
|
||||
if (!ftp_rename(ftp, src, src_len, dest, dest_len)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -1468,7 +1504,9 @@ PHP_FUNCTION(ftp_delete)
|
||||
|
||||
/* delete the file */
|
||||
if (!ftp_delete(ftp, file, file_len)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -1495,7 +1533,9 @@ PHP_FUNCTION(ftp_site)
|
||||
|
||||
/* send the site command */
|
||||
if (!ftp_site(ftp, cmd, cmd_len)) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
if (*ftp->inbuf) {
|
||||
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Bug #79100 (Wrong FTP error messages)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require 'skipif.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$bug79100 = true;
|
||||
require 'server.inc';
|
||||
|
||||
$ftp = ftp_connect("127.0.0.1", $port);
|
||||
if (!$ftp) die("Couldn't connect to the server");
|
||||
var_dump(ftp_login($ftp, 'user', 'pass'));
|
||||
var_dump(ftp_set_option($ftp, FTP_TIMEOUT_SEC, 1));
|
||||
ftp_systype($ftp);
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
Warning: ftp_systype(): %rConnection|Operation%r timed out in %s on line %d
|
||||
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Bug #80901 (Info leak in ftp extension)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require 'skipif.inc';
|
||||
?>
|
||||
--INI--
|
||||
log_errors_max_len=0
|
||||
--FILE--
|
||||
<?php
|
||||
$bug80901 = true;
|
||||
require 'server.inc';
|
||||
|
||||
$ftp = ftp_connect("127.0.0.1", $port);
|
||||
if (!$ftp) die("Couldn't connect to the server");
|
||||
var_dump(ftp_login($ftp, 'user', 'pass'));
|
||||
ftp_systype($ftp);
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
|
||||
Warning: ftp_systype(): **************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** in %s on line %d
|
||||
@@ -107,6 +107,7 @@ if ($pid) {
|
||||
fputs($s, "234 auth type accepted\r\n");
|
||||
} else {
|
||||
fputs($s, "666 dummy\r\n");
|
||||
sleep(1);
|
||||
fputs($s, "666 bogus msg\r\n");
|
||||
exit;
|
||||
}
|
||||
@@ -197,6 +198,10 @@ if ($pid) {
|
||||
} elseif ($buf === "SYST\r\n") {
|
||||
if (isset($bug27809)) {
|
||||
fputs($s, "215 OS/400 is the remote operating system. The TCP/IP version is \"V5R2M0\"\r\n");
|
||||
} elseif (isset($bug79100)) {
|
||||
// do nothing so test hits timeout
|
||||
} elseif (isset($bug80901)) {
|
||||
fputs($s, "\r\n" . str_repeat("*", 4096) . "\r\n");
|
||||
} else {
|
||||
fputs($s, "215 UNIX Type: L8.\r\n");
|
||||
}
|
||||
|
||||
+17
-7
@@ -60,13 +60,23 @@
|
||||
|
||||
static int le_gd, le_gd_font;
|
||||
|
||||
#include <gd.h>
|
||||
#include <gd_errors.h>
|
||||
#include <gdfontt.h> /* 1 Tiny font */
|
||||
#include <gdfonts.h> /* 2 Small font */
|
||||
#include <gdfontmb.h> /* 3 Medium bold font */
|
||||
#include <gdfontl.h> /* 4 Large font */
|
||||
#include <gdfontg.h> /* 5 Giant font */
|
||||
#ifdef HAVE_GD_BUNDLED
|
||||
# include "libgd/gd.h"
|
||||
# include "libgd/gd_errors.h"
|
||||
# include "libgd/gdfontt.h" /* 1 Tiny font */
|
||||
# include "libgd/gdfonts.h" /* 2 Small font */
|
||||
# include "libgd/gdfontmb.h" /* 3 Medium bold font */
|
||||
# include "libgd/gdfontl.h" /* 4 Large font */
|
||||
# include "libgd/gdfontg.h" /* 5 Giant font */
|
||||
#else
|
||||
# include <gd.h>
|
||||
# include <gd_errors.h>
|
||||
# include <gdfontt.h> /* 1 Tiny font */
|
||||
# include <gdfonts.h> /* 2 Small font */
|
||||
# include <gdfontmb.h> /* 3 Medium bold font */
|
||||
# include <gdfontl.h> /* 4 Large font */
|
||||
# include <gdfontg.h> /* 5 Giant font */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GD_FREETYPE) && defined(HAVE_GD_BUNDLED)
|
||||
# include <ft2build.h>
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
* (end code)
|
||||
**/
|
||||
|
||||
#include <gd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gd.h"
|
||||
|
||||
static int gdGuessBackgroundColorFromCorners(gdImagePtr im, int *color);
|
||||
static int gdColorMatch(gdImagePtr im, int col1, int col2, float threshold);
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ TODO:
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <gd.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
@@ -51,13 +51,13 @@
|
||||
----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <gd.h>
|
||||
#include <gdfonts.h>
|
||||
#include <gd_errors.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "gd.h"
|
||||
#include "gdfonts.h"
|
||||
#include "gd_errors.h"
|
||||
#include "wbmp.h"
|
||||
|
||||
|
||||
|
||||
@@ -3551,6 +3551,23 @@ PHP_FUNCTION(imap_fetch_overview)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_bool header_injection(zend_string *str, zend_bool adrlist)
|
||||
{
|
||||
char *p = ZSTR_VAL(str);
|
||||
|
||||
while ((p = strpbrk(p, "\r\n")) != NULL) {
|
||||
if (!(p[0] == '\r' && p[1] == '\n')
|
||||
/* adrlists do not support folding, but swallow trailing line breaks */
|
||||
&& !((adrlist && p[1] == '\0')
|
||||
/* other headers support folding */
|
||||
|| (!adrlist && (p[1] == ' ' || p[1] == '\t')))) {
|
||||
return 1;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* {{{ proto string imap_mail_compose(array envelope, array body)
|
||||
Create a MIME message based on given envelope and body sections */
|
||||
PHP_FUNCTION(imap_mail_compose)
|
||||
@@ -3571,6 +3588,13 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
return;
|
||||
}
|
||||
|
||||
#define CHECK_HEADER_INJECTION(zstr, adrlist, header) \
|
||||
if (header_injection(zstr, adrlist)) { \
|
||||
php_error_docref(NULL, E_WARNING, "header injection attempt in " header); \
|
||||
RETVAL_FALSE; \
|
||||
goto done; \
|
||||
}
|
||||
|
||||
#define PHP_RFC822_PARSE_ADRLIST(target, value) \
|
||||
str_copy = estrndup(Z_STRVAL_P(value), Z_STRLEN_P(value)); \
|
||||
rfc822_parse_adrlist(target, str_copy, "NO HOST"); \
|
||||
@@ -3579,46 +3603,57 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
env = mail_newenvelope();
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "remail", sizeof("remail") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "remail");
|
||||
env->remail = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "return_path", sizeof("return_path") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 1, "return_path");
|
||||
PHP_RFC822_PARSE_ADRLIST(&env->return_path, pvalue);
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "date", sizeof("date") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "date");
|
||||
env->date = (unsigned char*)cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "from", sizeof("from") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 1, "from");
|
||||
PHP_RFC822_PARSE_ADRLIST(&env->from, pvalue);
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "reply_to", sizeof("reply_to") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 1, "reply_to");
|
||||
PHP_RFC822_PARSE_ADRLIST(&env->reply_to, pvalue);
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "in_reply_to", sizeof("in_reply_to") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "in_reply_to");
|
||||
env->in_reply_to = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "subject", sizeof("subject") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "subject");
|
||||
env->subject = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "to", sizeof("to") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 1, "to");
|
||||
PHP_RFC822_PARSE_ADRLIST(&env->to, pvalue);
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "cc", sizeof("cc") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 1, "cc");
|
||||
PHP_RFC822_PARSE_ADRLIST(&env->cc, pvalue);
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "bcc", sizeof("bcc") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 1, "bcc");
|
||||
PHP_RFC822_PARSE_ADRLIST(&env->bcc, pvalue);
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(envelope), "message_id", sizeof("message_id") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "message_id");
|
||||
env->message_id=cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
|
||||
@@ -3629,6 +3664,7 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pvalue), env_data) {
|
||||
custom_headers_param = mail_newbody_parameter();
|
||||
convert_to_string_ex(env_data);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(env_data), 0, "custom_headers");
|
||||
custom_headers_param->value = (char *) fs_get(Z_STRLEN_P(env_data) + 1);
|
||||
custom_headers_param->attribute = NULL;
|
||||
memcpy(custom_headers_param->value, Z_STRVAL_P(env_data), Z_STRLEN_P(env_data) + 1);
|
||||
@@ -3667,6 +3703,7 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "charset", sizeof("charset") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body charset");
|
||||
tmp_param = mail_newbody_parameter();
|
||||
tmp_param->value = cpystr(Z_STRVAL_P(pvalue));
|
||||
tmp_param->attribute = cpystr("CHARSET");
|
||||
@@ -3679,9 +3716,11 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
SEPARATE_ARRAY(pvalue);
|
||||
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
|
||||
if (key == NULL) continue;
|
||||
CHECK_HEADER_INJECTION(key, 0, "body disposition key");
|
||||
disp_param = mail_newbody_parameter();
|
||||
disp_param->attribute = cpystr(ZSTR_VAL(key));
|
||||
convert_to_string_ex(disp_data);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(disp_data), 0, "body disposition value");
|
||||
disp_param->value = (char *) fs_get(Z_STRLEN_P(disp_data) + 1);
|
||||
memcpy(disp_param->value, Z_STRVAL_P(disp_data), Z_STRLEN_P(disp_data) + 1);
|
||||
disp_param->next = tmp_param;
|
||||
@@ -3692,18 +3731,22 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "subtype", sizeof("subtype") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body subtype");
|
||||
bod->subtype = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "id", sizeof("id") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body id");
|
||||
bod->id = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "description", sizeof("description") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body description");
|
||||
bod->description = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "disposition.type", sizeof("disposition.type") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body disposition.type");
|
||||
bod->disposition.type = (char *) fs_get(Z_STRLEN_P(pvalue) + 1);
|
||||
memcpy(bod->disposition.type, Z_STRVAL_P(pvalue), Z_STRLEN_P(pvalue)+1);
|
||||
}
|
||||
@@ -3713,9 +3756,11 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
SEPARATE_ARRAY(pvalue);
|
||||
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
|
||||
if (key == NULL) continue;
|
||||
CHECK_HEADER_INJECTION(key, 0, "body type.parameters key");
|
||||
disp_param = mail_newbody_parameter();
|
||||
disp_param->attribute = cpystr(ZSTR_VAL(key));
|
||||
convert_to_string_ex(disp_data);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(disp_data), 0, "body type.parameters value");
|
||||
disp_param->value = (char *) fs_get(Z_STRLEN_P(disp_data) + 1);
|
||||
memcpy(disp_param->value, Z_STRVAL_P(disp_data), Z_STRLEN_P(disp_data) + 1);
|
||||
disp_param->next = tmp_param;
|
||||
@@ -3746,6 +3791,7 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "md5", sizeof("md5") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body md5");
|
||||
bod->md5 = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
} else if (Z_TYPE_P(data) == IS_ARRAY && topbod->type == TYPEMULTIPART) {
|
||||
@@ -3778,6 +3824,7 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "charset", sizeof("charset") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body charset");
|
||||
tmp_param = mail_newbody_parameter();
|
||||
tmp_param->value = (char *) fs_get(Z_STRLEN_P(pvalue) + 1);
|
||||
memcpy(tmp_param->value, Z_STRVAL_P(pvalue), Z_STRLEN_P(pvalue) + 1);
|
||||
@@ -3791,9 +3838,11 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
SEPARATE_ARRAY(pvalue);
|
||||
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
|
||||
if (key == NULL) continue;
|
||||
CHECK_HEADER_INJECTION(key, 0, "body type.parameters key");
|
||||
disp_param = mail_newbody_parameter();
|
||||
disp_param->attribute = cpystr(ZSTR_VAL(key));
|
||||
convert_to_string_ex(disp_data);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(disp_data), 0, "body type.parameters value");
|
||||
disp_param->value = (char *)fs_get(Z_STRLEN_P(disp_data) + 1);
|
||||
memcpy(disp_param->value, Z_STRVAL_P(disp_data), Z_STRLEN_P(disp_data) + 1);
|
||||
disp_param->next = tmp_param;
|
||||
@@ -3804,18 +3853,22 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "subtype", sizeof("subtype") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body subtype");
|
||||
bod->subtype = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "id", sizeof("id") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body id");
|
||||
bod->id = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "description", sizeof("description") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body description");
|
||||
bod->description = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "disposition.type", sizeof("disposition.type") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body disposition.type");
|
||||
bod->disposition.type = (char *) fs_get(Z_STRLEN_P(pvalue) + 1);
|
||||
memcpy(bod->disposition.type, Z_STRVAL_P(pvalue), Z_STRLEN_P(pvalue)+1);
|
||||
}
|
||||
@@ -3825,9 +3878,11 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
SEPARATE_ARRAY(pvalue);
|
||||
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(pvalue), key, disp_data) {
|
||||
if (key == NULL) continue;
|
||||
CHECK_HEADER_INJECTION(key, 0, "body disposition key");
|
||||
disp_param = mail_newbody_parameter();
|
||||
disp_param->attribute = cpystr(ZSTR_VAL(key));
|
||||
convert_to_string_ex(disp_data);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(disp_data), 0, "body disposition value");
|
||||
disp_param->value = (char *) fs_get(Z_STRLEN_P(disp_data) + 1);
|
||||
memcpy(disp_param->value, Z_STRVAL_P(disp_data), Z_STRLEN_P(disp_data) + 1);
|
||||
disp_param->next = tmp_param;
|
||||
@@ -3858,6 +3913,7 @@ PHP_FUNCTION(imap_mail_compose)
|
||||
}
|
||||
if ((pvalue = zend_hash_str_find(Z_ARRVAL_P(data), "md5", sizeof("md5") - 1)) != NULL) {
|
||||
convert_to_string_ex(pvalue);
|
||||
CHECK_HEADER_INJECTION(Z_STR_P(pvalue), 0, "body md5");
|
||||
bod->md5 = cpystr(Z_STRVAL_P(pvalue));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
Bug #80710 (imap_mail_compose() header injection) - MIME Splitting Attack
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("imap")) die("skip imap extension not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$envelope["from"]= "joe@example.com\n From : X-INJECTED";
|
||||
$envelope["to"] = "foo@example.com\nFrom: X-INJECTED";
|
||||
$envelope["cc"] = "bar@example.com\nFrom: X-INJECTED";
|
||||
$envelope["subject"] = "bar@example.com\n\n From : X-INJECTED";
|
||||
$envelope["x-remail"] = "bar@example.com\nFrom: X-INJECTED";
|
||||
$envelope["something"] = "bar@example.com\nFrom: X-INJECTED";
|
||||
|
||||
$part1["type"] = TYPEMULTIPART;
|
||||
$part1["subtype"] = "mixed";
|
||||
|
||||
$part2["type"] = TYPEAPPLICATION;
|
||||
$part2["encoding"] = ENCBINARY;
|
||||
$part2["subtype"] = "octet-stream\nContent-Type: X-INJECTED";
|
||||
$part2["description"] = "some file\nContent-Type: X-INJECTED";
|
||||
$part2["contents.data"] = "ABC\nContent-Type: X-INJECTED";
|
||||
|
||||
$part3["type"] = TYPETEXT;
|
||||
$part3["subtype"] = "plain";
|
||||
$part3["description"] = "description3";
|
||||
$part3["contents.data"] = "contents.data3\n\n\n\t";
|
||||
|
||||
$body[1] = $part1;
|
||||
$body[2] = $part2;
|
||||
$body[3] = $part3;
|
||||
|
||||
echo imap_mail_compose($envelope, $body);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: imap_mail_compose(): header injection attempt in from in %s on line %d
|
||||
@@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
Bug #80710 (imap_mail_compose() header injection) - Remail
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("imap")) die("skip imap extension not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$envelope["from"]= "joe@example.com\n From : X-INJECTED";
|
||||
$envelope["to"] = "foo@example.com\nFrom: X-INJECTED";
|
||||
$envelope["cc"] = "bar@example.com\nFrom: X-INJECTED";
|
||||
$envelope["subject"] = "bar@example.com\n\n From : X-INJECTED";
|
||||
$envelope["remail"] = "X-INJECTED-REMAIL: X-INJECTED\nFrom: X-INJECTED-REMAIL-FROM"; //<--- Injected as first hdr
|
||||
$envelope["something"] = "bar@example.com\nFrom: X-INJECTED";
|
||||
|
||||
$part1["type"] = TYPEMULTIPART;
|
||||
$part1["subtype"] = "mixed";
|
||||
|
||||
$part2["type"] = TYPEAPPLICATION;
|
||||
$part2["encoding"] = ENCBINARY;
|
||||
$part2["subtype"] = "octet-stream\nContent-Type: X-INJECTED";
|
||||
$part2["description"] = "some file\nContent-Type: X-INJECTED";
|
||||
$part2["contents.data"] = "ABC\nContent-Type: X-INJECTED";
|
||||
|
||||
$part3["type"] = TYPETEXT;
|
||||
$part3["subtype"] = "plain";
|
||||
$part3["description"] = "description3";
|
||||
$part3["contents.data"] = "contents.data3\n\n\n\t";
|
||||
|
||||
$body[1] = $part1;
|
||||
$body[2] = $part2;
|
||||
$body[3] = $part3;
|
||||
|
||||
echo imap_mail_compose($envelope, $body);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: imap_mail_compose(): header injection attempt in remail in %s on line %d
|
||||
@@ -175,6 +175,7 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func)
|
||||
return ZEND_NAN;
|
||||
}
|
||||
|
||||
try_again:
|
||||
switch (Z_TYPE_P(z)) {
|
||||
case IS_STRING:
|
||||
type = is_numeric_string(Z_STRVAL_P(z), Z_STRLEN_P(z), &lv, &rv, 0);
|
||||
@@ -227,6 +228,9 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func)
|
||||
efree(message);
|
||||
}
|
||||
break;
|
||||
case IS_REFERENCE:
|
||||
z = Z_REFVAL_P(z);
|
||||
goto try_again;
|
||||
default:
|
||||
spprintf(&message, 0, "%s: invalid PHP type for date", func);
|
||||
intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Bug #80763 (msgfmt_format() does not accept DateTime references)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('intl')) die('skip intl extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$today = new DateTime('2021-02-17 12:00:00');
|
||||
$formatter = new \MessageFormatter('en_US', 'Today is {today, date, full}.');
|
||||
$params = ['today' => $today];
|
||||
array_walk($params, fn() => 1);
|
||||
var_dump($formatter->format($params));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(38) "Today is Wednesday, February 17, 2021."
|
||||
+49
-1
@@ -409,6 +409,54 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Check if there's been an external transport protocol with an encoding information */
|
||||
if (enc == XML_CHAR_ENCODING_NONE) {
|
||||
php_stream *s = (php_stream *) context;
|
||||
|
||||
if (Z_TYPE(s->wrapperdata) == IS_ARRAY) {
|
||||
zval *header;
|
||||
|
||||
ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL(s->wrapperdata), header) {
|
||||
const char buf[] = "Content-Type:";
|
||||
if (Z_TYPE_P(header) == IS_STRING &&
|
||||
!zend_binary_strncasecmp(Z_STRVAL_P(header), Z_STRLEN_P(header), buf, sizeof(buf)-1, sizeof(buf)-1)) {
|
||||
char *needle = estrdup("charset=");
|
||||
char *haystack = estrndup(Z_STRVAL_P(header), Z_STRLEN_P(header));
|
||||
char *encoding = php_stristr(haystack, needle, Z_STRLEN_P(header), sizeof("charset=")-1);
|
||||
|
||||
if (encoding) {
|
||||
char *end;
|
||||
|
||||
encoding += sizeof("charset=")-1;
|
||||
if (*encoding == '"') {
|
||||
encoding++;
|
||||
}
|
||||
end = strchr(encoding, ';');
|
||||
if (end == NULL) {
|
||||
end = encoding + strlen(encoding);
|
||||
}
|
||||
end--; /* end == encoding-1 isn't a buffer underrun */
|
||||
while (*end == ' ' || *end == '\t') {
|
||||
end--;
|
||||
}
|
||||
if (*end == '"') {
|
||||
end--;
|
||||
}
|
||||
if (encoding >= end) continue;
|
||||
*(end+1) = '\0';
|
||||
enc = xmlParseCharEncoding(encoding);
|
||||
if (enc <= XML_CHAR_ENCODING_NONE) {
|
||||
enc = XML_CHAR_ENCODING_NONE;
|
||||
}
|
||||
}
|
||||
efree(haystack);
|
||||
efree(needle);
|
||||
break; /* found content-type */
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate the Input buffer front-end. */
|
||||
ret = xmlAllocParserInputBuffer(enc);
|
||||
if (ret != NULL) {
|
||||
@@ -1134,7 +1182,7 @@ static PHP_FUNCTION(libxml_set_external_entity_loader)
|
||||
/* {{{ Common functions shared by extensions */
|
||||
int php_libxml_xmlCheckUTF8(const unsigned char *s)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
unsigned char c;
|
||||
|
||||
for (i = 0; (c = s[i++]);) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
--TEST--
|
||||
Bug #51903 (simplexml_load_file() doesn't use HTTP headers)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('simplexml')) die('skip simplexml extension not available');
|
||||
if (@!include "./ext/standard/tests/http/server.inc") die('skip server.inc not available');
|
||||
http_server_skipif('tcp://127.0.0.1:12342');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require "./ext/standard/tests/http/server.inc";
|
||||
$responses = [
|
||||
"data://text/plain,HTTP/1.1 200 OK\r\n"
|
||||
. "Content-Type: text/xml; charset=ISO-8859-1\r\n\r\n"
|
||||
. "<?xml version=\"1.0\"?>\n"
|
||||
. "<root>\xE4\xF6\xFC</root>\n",
|
||||
"data://text/plain,HTTP/1.1 200 OK\r\n"
|
||||
. "Content-Type: text/xml; charset=ISO-8859-1; foo=bar\r\n\r\n"
|
||||
. "<?xml version=\"1.0\"?>\n"
|
||||
. "<root>\xE4\xF6\xFC</root>\n",
|
||||
"data://text/plain,HTTP/1.1 200 OK\r\n"
|
||||
. "Content-Type: text/xml; charset=\"ISO-8859-1\" ; foo=bar\r\n\r\n"
|
||||
. "<?xml version=\"1.0\"?>\n"
|
||||
. "<root>\xE4\xF6\xFC</root>\n",
|
||||
];
|
||||
$pid = http_server('tcp://127.0.0.1:12342', $responses);
|
||||
|
||||
for ($i = 0; $i < count($responses); $i++) {
|
||||
$sxe = simplexml_load_file('http://127.0.0.1:12342/');
|
||||
echo "$sxe\n";
|
||||
}
|
||||
|
||||
http_server_kill($pid);
|
||||
?>
|
||||
--EXPECT--
|
||||
äöü
|
||||
äöü
|
||||
äöü
|
||||
@@ -3286,6 +3286,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons
|
||||
}
|
||||
/* convert value */
|
||||
ZEND_ASSERT(entry);
|
||||
try_again:
|
||||
switch(Z_TYPE_P(entry)) {
|
||||
case IS_STRING:
|
||||
cval = php_mb_convert_encoding(Z_STRVAL_P(entry), Z_STRLEN_P(entry), _to_encoding, _from_encodings, &cval_len);
|
||||
@@ -3307,6 +3308,9 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons
|
||||
ZVAL_EMPTY_ARRAY(&entry_tmp);
|
||||
}
|
||||
break;
|
||||
case IS_REFERENCE:
|
||||
entry = Z_REFVAL_P(entry);
|
||||
goto try_again;
|
||||
case IS_OBJECT:
|
||||
default:
|
||||
if (key) {
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
--TEST--
|
||||
Bug #81011 (mb_convert_encoding removes references from arrays)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('mbstring')) die("skip mbstring extension not available");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$array = [
|
||||
'ads' => [
|
||||
123 => ['name' => 'this', 'id' => 444],
|
||||
234 => ['name' => 'that', 'id' => 555],
|
||||
],
|
||||
'other' => ['one', 'two']
|
||||
];
|
||||
|
||||
// we modify array elements using reference
|
||||
foreach( $array['ads'] as &$ad ){
|
||||
$ad['premium'] = (int)($ad['id'] == 555);
|
||||
}
|
||||
|
||||
var_dump($array);
|
||||
var_dump(mb_convert_encoding($array, 'UTF-8', 'UTF-8'));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
["ads"]=>
|
||||
array(2) {
|
||||
[123]=>
|
||||
array(3) {
|
||||
["name"]=>
|
||||
string(4) "this"
|
||||
["id"]=>
|
||||
int(444)
|
||||
["premium"]=>
|
||||
int(0)
|
||||
}
|
||||
[234]=>
|
||||
&array(3) {
|
||||
["name"]=>
|
||||
string(4) "that"
|
||||
["id"]=>
|
||||
int(555)
|
||||
["premium"]=>
|
||||
int(1)
|
||||
}
|
||||
}
|
||||
["other"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
[1]=>
|
||||
string(3) "two"
|
||||
}
|
||||
}
|
||||
array(2) {
|
||||
["ads"]=>
|
||||
array(2) {
|
||||
[123]=>
|
||||
array(3) {
|
||||
["name"]=>
|
||||
string(4) "this"
|
||||
["id"]=>
|
||||
int(444)
|
||||
["premium"]=>
|
||||
int(0)
|
||||
}
|
||||
[234]=>
|
||||
array(3) {
|
||||
["name"]=>
|
||||
string(4) "that"
|
||||
["id"]=>
|
||||
int(555)
|
||||
["premium"]=>
|
||||
int(1)
|
||||
}
|
||||
}
|
||||
["other"]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
[1]=>
|
||||
string(3) "two"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
--TEST--
|
||||
Bug #74779 (x() and y() truncating floats to integers)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once('skipif.inc');
|
||||
require_once('skipifconnectfailure.inc');
|
||||
if (!setlocale(LC_NUMERIC, "de_DE", "de_DE.UTF-8", "de-DE")) die('skip locale not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("connect.inc");
|
||||
|
||||
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
|
||||
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
|
||||
$host, $user, $db, $port, $socket);
|
||||
}
|
||||
|
||||
if (!setlocale(LC_NUMERIC, "de_DE", "de_DE.UTF-8", "de-DE")) {
|
||||
echo "[002] Cannot set locale\n";
|
||||
}
|
||||
|
||||
if (!$link->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true)) {
|
||||
printf("[003] [%d] %s\n", $link->errno, $link->error);
|
||||
}
|
||||
|
||||
if (!$result = $link->query("SELECT ST_Y(Point(56.7, 53.34))")) {
|
||||
printf("[004] [%d] %s\n", $link->errno, $link->error);
|
||||
}
|
||||
|
||||
if (!$array = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
printf("[005] [%d] %s\n", $link->errno, $link->error);
|
||||
}
|
||||
|
||||
var_dump($array);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
["ST_Y(Point(56.7, 53.34))"]=>
|
||||
float(53,34)
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
--TEST--
|
||||
Bug #80837 Calling stmt_store_result after fetch doesn't throw an error
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once 'skipif.inc';
|
||||
require_once 'skipifconnectfailure.inc';
|
||||
if (!defined('MYSQLI_STORE_RESULT_COPY_DATA')) die('skip requires mysqlnd');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once "connect.inc";
|
||||
|
||||
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
|
||||
|
||||
$mysqli->query('DROP TABLE IF EXISTS test');
|
||||
$mysqli->query('CREATE TABLE test (b int)');
|
||||
$mysqli->query('INSERT INTO test VALUES (1),(2),(3)');
|
||||
|
||||
$statement = $mysqli->prepare("SELECT b FROM test");
|
||||
$statement->execute();
|
||||
$statement->bind_result($name);
|
||||
$statement->fetch();
|
||||
try {
|
||||
$statement->store_result();
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
$mysqli->close();
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once "clean_table.inc";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Commands out of sync; you can't run this command now
|
||||
@@ -19,8 +19,8 @@ if (!$res = $link->query("SHOW PLUGINS"))
|
||||
|
||||
$have_pam = false;
|
||||
while ($row = $res->fetch_assoc()) {
|
||||
if (isset($row['Name']) && ('mysql_clear_password' == $row['Name'])) {
|
||||
$have_pam = true;
|
||||
if (isset($row['Name']) && in_array($row['Name'], array('pam', 'authentication_pam', 'auth_pam_compat'))) {
|
||||
$have_pam = $row['Name'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,54 @@ $res->close();
|
||||
if (!$have_pam)
|
||||
die("SKIP Server PAM plugin not installed");
|
||||
|
||||
if ($have_pam == 'pam') {
|
||||
/* MariaDB - needs system variable pam_use_cleartext_plugin=ON to be set */
|
||||
if (!$res = mysqli_query($link, 'SHOW GLOBAL VARIABLES LIKE "pam_use_cleartext_plugin"'))
|
||||
die(sprintf("SKIP MariaDB probe of GLOBAL VARIABLES failed [%d] %s\n",
|
||||
mysqli_errno($link), mysqli_error($link)));
|
||||
$pam_use_cleartext_plugin = mysqli_fetch_row($res);
|
||||
mysqli_free_result($res);
|
||||
if (!$pam_use_cleartext_plugin or $pam_use_cleartext_plugin[1]!='ON')
|
||||
die("SKIP Server setting pam_use_cleartext_plugin!=ON");
|
||||
|
||||
$pam_service = file_get_contents('/etc/pam.d/mysql');
|
||||
} elseif ($have_pam == 'authentication_pam') {
|
||||
/*
|
||||
required MySQL syntax:
|
||||
https://dev.mysql.com/doc/refman/8.0/en/pam-pluggable-authentication.html#pam-pluggable-authentication-usage
|
||||
*/
|
||||
$have_pam .= " AS 'mysql-unix'";
|
||||
$pam_service = file_get_contents('/etc/pam.d/mysql-unix');
|
||||
} else {
|
||||
$pam_service = file_get_contents('/etc/pam.d/mysql');
|
||||
}
|
||||
$auth = 0;
|
||||
$account = 0;
|
||||
foreach (explode("\n", $pam_service) as $line)
|
||||
{
|
||||
if (preg_match('/^auth/', $line)) {
|
||||
$auth = 1;
|
||||
} elseif (preg_match('/^account/', $line)) {
|
||||
$account = 1;
|
||||
}
|
||||
}
|
||||
if (!$auth) {
|
||||
die("SKIP pam service file missing 'auth' directive");
|
||||
}
|
||||
if (!$account) {
|
||||
die("SKIP pam service file missing 'account' directive");
|
||||
}
|
||||
|
||||
if (!posix_getpwnam('pamtest')) {
|
||||
die("SKIP no pamtest user");
|
||||
}
|
||||
/* Password of user 'pamtest' should be set to 'pamtest' */
|
||||
|
||||
mysqli_query($link, 'DROP USER pamtest');
|
||||
mysqli_query($link, 'DROP USER pamtest@localhost');
|
||||
|
||||
if (!mysqli_query($link, 'CREATE USER pamtest@"%" IDENTIFIED WITH mysql_clear_password') ||
|
||||
!mysqli_query($link, 'CREATE USER pamtest@"localhost" IDENTIFIED WITH mysql_clear_password')) {
|
||||
if (!mysqli_query($link, "CREATE USER pamtest@'%' IDENTIFIED WITH $have_pam") ||
|
||||
!mysqli_query($link, "CREATE USER pamtest@'localhost' IDENTIFIED WITH $have_pam")) {
|
||||
printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
|
||||
mysqli_close($link);
|
||||
die("skip CREATE USER failed");
|
||||
@@ -60,8 +102,8 @@ max_execution_time=240
|
||||
require_once('table.inc');
|
||||
|
||||
if (!$link = my_mysqli_connect($host, 'pamtest', 'pamtest', $db, $port, $socket)) {
|
||||
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
|
||||
$host, $user, $db, $port, $socket);
|
||||
printf("[001] Cannot connect to the server using host=%s, user=pamtest, passwd=pamtest dbname=%s, port=%s, socket=%s\n",
|
||||
$host, $db, $port, $socket);
|
||||
} else {
|
||||
|
||||
if (!$res = $link->query("SELECT id FROM test WHERE id = 1"))
|
||||
@@ -88,6 +130,4 @@ max_execution_time=240
|
||||
mysqli_query($link, 'DROP USER pamtest@localhost');
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: mysqli_real_connect(): (28000/1045): Access denied for user %s
|
||||
[001] Cannot connect to the server using host=%s
|
||||
done!
|
||||
@@ -652,7 +652,11 @@ mysqlnd_pam_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self,
|
||||
if (passwd && passwd_len) {
|
||||
ret = (zend_uchar*) zend_strndup(passwd, passwd_len);
|
||||
}
|
||||
*auth_data_len = passwd_len;
|
||||
/*
|
||||
Trailing null required. bug#78680
|
||||
https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_authentication_methods_clear_text_password.html
|
||||
*/
|
||||
*auth_data_len = passwd_len + 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const s)
|
||||
|
||||
/* Nothing to store for UPSERT/LOAD DATA*/
|
||||
if (!mysqlnd_stmt_check_state(stmt)) {
|
||||
SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
|
||||
DBG_RETURN(NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1216,8 +1216,9 @@ php_mysqlnd_rset_field_read(MYSQLND_CONN_DATA * conn, void * _packet)
|
||||
DBG_RETURN(PASS);
|
||||
} else if (EODATA_MARKER == *p && packet->header.size < 8) {
|
||||
/* Premature EOF. That should be COM_FIELD_LIST. But we don't support COM_FIELD_LIST anymore, thus this should not happen */
|
||||
DBG_INF("Premature EOF. That should be COM_FIELD_LIST");
|
||||
DBG_RETURN(PASS);
|
||||
DBG_ERR("Premature EOF. That should be COM_FIELD_LIST");
|
||||
php_error_docref(NULL, E_WARNING, "Premature EOF in result field metadata");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
||||
meta = packet->metadata;
|
||||
@@ -1679,7 +1680,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_ROW_BUFFER * row_buffer, zval *
|
||||
zend_uchar save = *(p + len);
|
||||
/* We have to make it ASCIIZ temporarily */
|
||||
*(p + len) = '\0';
|
||||
ZVAL_DOUBLE(current_field, atof((char *) p));
|
||||
ZVAL_DOUBLE(current_field, zend_strtod((char *) p, NULL));
|
||||
*(p + len) = save;
|
||||
}
|
||||
#endif /* MYSQLND_STRING_TO_INT_CONVERSION */
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
--------------------------------------------------------------------
|
||||
The PHP License, version 3.01
|
||||
Copyright (c) 1999 - 2019 The PHP Group. All rights reserved.
|
||||
Copyright (c) 1999 - 2021 The PHP Group. All rights reserved.
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
+36
-1
@@ -1814,6 +1814,9 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
|
||||
} else if (result->values[i].vallen == SQL_NULL_DATA) {
|
||||
ZVAL_NULL(&tmp);
|
||||
break;
|
||||
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1);
|
||||
ZVAL_FALSE(&tmp);
|
||||
} else {
|
||||
ZVAL_STRINGL(&tmp, buf, result->values[i].vallen);
|
||||
}
|
||||
@@ -1823,6 +1826,10 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
|
||||
if (result->values[i].vallen == SQL_NULL_DATA) {
|
||||
ZVAL_NULL(&tmp);
|
||||
break;
|
||||
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1);
|
||||
ZVAL_FALSE(&tmp);
|
||||
break;
|
||||
}
|
||||
ZVAL_STRINGL(&tmp, result->values[i].value, result->values[i].vallen);
|
||||
break;
|
||||
@@ -1970,6 +1977,9 @@ PHP_FUNCTION(odbc_fetch_into)
|
||||
} else if (result->values[i].vallen == SQL_NULL_DATA) {
|
||||
ZVAL_NULL(&tmp);
|
||||
break;
|
||||
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1);
|
||||
ZVAL_FALSE(&tmp);
|
||||
} else {
|
||||
ZVAL_STRINGL(&tmp, buf, result->values[i].vallen);
|
||||
}
|
||||
@@ -1979,6 +1989,10 @@ PHP_FUNCTION(odbc_fetch_into)
|
||||
if (result->values[i].vallen == SQL_NULL_DATA) {
|
||||
ZVAL_NULL(&tmp);
|
||||
break;
|
||||
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1);
|
||||
ZVAL_FALSE(&tmp);
|
||||
break;
|
||||
}
|
||||
ZVAL_STRINGL(&tmp, result->values[i].value, result->values[i].vallen);
|
||||
break;
|
||||
@@ -2211,6 +2225,10 @@ PHP_FUNCTION(odbc_result)
|
||||
} else if (result->values[field_ind].vallen == SQL_NULL_DATA) {
|
||||
zend_string_efree(field_str);
|
||||
RETURN_NULL();
|
||||
} else if (result->values[field_ind].vallen == SQL_NO_TOTAL) {
|
||||
zend_string_efree(field_str);
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", field_ind + 1);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* Reduce fieldlen by 1 if we have char data. One day we might
|
||||
have binary strings... */
|
||||
@@ -2234,6 +2252,9 @@ PHP_FUNCTION(odbc_result)
|
||||
default:
|
||||
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
|
||||
RETURN_NULL();
|
||||
} else if (result->values[field_ind].vallen == SQL_NO_TOTAL) {
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", field_ind + 1);
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
RETURN_STRINGL(result->values[field_ind].value, result->values[field_ind].vallen);
|
||||
}
|
||||
@@ -2265,6 +2286,10 @@ PHP_FUNCTION(odbc_result)
|
||||
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
|
||||
efree(field);
|
||||
RETURN_NULL();
|
||||
} else if (result->values[field_ind].vallen == SQL_NO_TOTAL) {
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", field_ind + 1);
|
||||
efree(field);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
/* chop the trailing \0 by outputting only 4095 bytes */
|
||||
PHPWRITE(field,(rc == SQL_SUCCESS_WITH_INFO) ? 4095 : result->values[field_ind].vallen);
|
||||
@@ -2370,7 +2395,14 @@ PHP_FUNCTION(odbc_result_all)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (rc == SQL_SUCCESS_WITH_INFO) {
|
||||
PHPWRITE(buf, result->longreadlen);
|
||||
if (result->values[i].vallen == SQL_NO_TOTAL) {
|
||||
php_printf("</td></tr></table>");
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%zu (driver cannot determine length)", i + 1);
|
||||
efree(buf);
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
PHPWRITE(buf, result->longreadlen);
|
||||
}
|
||||
} else if (rc != SQL_SUCCESS) {
|
||||
php_printf("</td></tr></table>");
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%zu (retcode %u)", i + 1, rc);
|
||||
@@ -2387,6 +2419,9 @@ PHP_FUNCTION(odbc_result_all)
|
||||
default:
|
||||
if (result->values[i].vallen == SQL_NULL_DATA) {
|
||||
php_printf("<td>NULL</td>");
|
||||
} else if (result->values[i].vallen == SQL_NO_TOTAL) {
|
||||
php_error_docref(NULL, E_WARNING, "Cannot get data of column #%zu (driver cannot determine length)", i + 1);
|
||||
php_printf("<td>FALSE</td>");
|
||||
} else {
|
||||
php_printf("<td>%s</td>", result->values[i].value);
|
||||
}
|
||||
|
||||
@@ -368,6 +368,10 @@ static zend_bool try_remove_var_def(context *ctx, int free_var, int use_chain, z
|
||||
return 0;
|
||||
}
|
||||
|
||||
static zend_always_inline zend_bool may_be_refcounted(uint32_t type) {
|
||||
return (type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) != 0;
|
||||
}
|
||||
|
||||
/* Returns whether the instruction has been DCEd */
|
||||
static zend_bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
|
||||
zend_ssa *ssa = ctx->ssa;
|
||||
@@ -379,16 +383,15 @@ static zend_bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
|
||||
}
|
||||
|
||||
/* We mark FREEs as dead, but they're only really dead if the destroyed var is dead */
|
||||
if (opline->opcode == ZEND_FREE
|
||||
&& (ssa->var_info[ssa_op->op1_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))
|
||||
if (opline->opcode == ZEND_FREE && may_be_refcounted(ssa->var_info[ssa_op->op1_use].type)
|
||||
&& !is_var_dead(ctx, ssa_op->op1_use)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((opline->op1_type & (IS_VAR|IS_TMP_VAR))&& !is_var_dead(ctx, ssa_op->op1_use)) {
|
||||
if (!try_remove_var_def(ctx, ssa_op->op1_use, ssa_op->op1_use_chain, opline)) {
|
||||
if (ssa->var_info[ssa_op->op1_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)
|
||||
&& opline->opcode != ZEND_CASE) {
|
||||
if (may_be_refcounted(ssa->var_info[ssa_op->op1_use].type)
|
||||
&& opline->opcode != ZEND_CASE) {
|
||||
free_var = ssa_op->op1_use;
|
||||
free_var_type = opline->op1_type;
|
||||
}
|
||||
@@ -396,7 +399,7 @@ static zend_bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
|
||||
}
|
||||
if ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) && !is_var_dead(ctx, ssa_op->op2_use)) {
|
||||
if (!try_remove_var_def(ctx, ssa_op->op2_use, ssa_op->op2_use_chain, opline)) {
|
||||
if (ssa->var_info[ssa_op->op2_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) {
|
||||
if (may_be_refcounted(ssa->var_info[ssa_op->op2_use].type)) {
|
||||
if (free_var >= 0) {
|
||||
// TODO: We can't free two vars. Keep instruction alive.
|
||||
zend_bitset_excl(ctx->instr_dead, opline - ctx->op_array->opcodes);
|
||||
@@ -503,6 +506,17 @@ int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, zend_bool reor
|
||||
ctx.phi_dead = alloca(sizeof(zend_ulong) * ctx.phi_worklist_len);
|
||||
memset(ctx.phi_dead, 0xff, sizeof(zend_ulong) * ctx.phi_worklist_len);
|
||||
|
||||
/* Mark non-CV phis as live. Even if the result is unused, we generally cannot remove one
|
||||
* of the producing instructions, as it combines producing the result with control flow.
|
||||
* This can be made more precise if there are any cases where this is not the case. */
|
||||
FOREACH_PHI(phi) {
|
||||
if (phi->var >= op_array->last_var
|
||||
&& may_be_refcounted(ssa->var_info[phi->ssa_var].type)) {
|
||||
zend_bitset_excl(ctx.phi_dead, phi->ssa_var);
|
||||
add_phi_sources_to_worklists(&ctx, phi, 0);
|
||||
}
|
||||
} FOREACH_PHI_END();
|
||||
|
||||
/* Mark reacable instruction without side effects as dead */
|
||||
int b = ssa->cfg.blocks_count;
|
||||
while (b > 0) {
|
||||
|
||||
@@ -2006,7 +2006,7 @@ static void sccp_mark_feasible_successors(
|
||||
scdf_mark_edge_feasible(scdf, block_num, target);
|
||||
return;
|
||||
}
|
||||
s = 0;
|
||||
s = block->successors_count - 1;
|
||||
break;
|
||||
case ZEND_SWITCH_STRING:
|
||||
if (Z_TYPE_P(op1) == IS_STRING) {
|
||||
@@ -2024,7 +2024,7 @@ static void sccp_mark_feasible_successors(
|
||||
scdf_mark_edge_feasible(scdf, block_num, target);
|
||||
return;
|
||||
}
|
||||
s = 0;
|
||||
s = block->successors_count - 1;
|
||||
break;
|
||||
default:
|
||||
for (s = 0; s < block->successors_count; s++) {
|
||||
|
||||
@@ -439,7 +439,7 @@ static const func_info_t func_infos[] = {
|
||||
F1("base64_decode", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
|
||||
F1("base64_encode", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
|
||||
F1("password_hash", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
|
||||
F1("password_get_info", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
|
||||
F1("password_get_info", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
|
||||
F0("password_needs_rehash", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
F0("password_verify", MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
F1("convert_uuencode", MAY_BE_FALSE | MAY_BE_STRING),
|
||||
@@ -884,7 +884,7 @@ static const func_info_t func_infos[] = {
|
||||
F1("gmstrftime", MAY_BE_FALSE | MAY_BE_STRING),
|
||||
F0("time", MAY_BE_LONG),
|
||||
F1("localtime", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG),
|
||||
F1("getdate", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
|
||||
F1("getdate", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
|
||||
F1("date_create", MAY_BE_FALSE | MAY_BE_OBJECT),
|
||||
F1("date_create_immutable", MAY_BE_FALSE | MAY_BE_OBJECT),
|
||||
F1("date_create_from_format", MAY_BE_FALSE | MAY_BE_OBJECT),
|
||||
@@ -949,7 +949,7 @@ static const func_info_t func_infos[] = {
|
||||
F0("mysqli_savepoint", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
F0("mysqli_release_savepoint", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
F1("mysqli_fetch_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
|
||||
F1("mysqli_fetch_assoc", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
|
||||
F1("mysqli_fetch_assoc", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
|
||||
F1("mysqli_fetch_all", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
|
||||
F1("mysqli_fetch_object", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_OBJECT),
|
||||
F0("mysqli_free_result", MAY_BE_NULL),
|
||||
@@ -1040,7 +1040,7 @@ static const func_info_t func_infos[] = {
|
||||
F1("curl_version", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
|
||||
F0("curl_setopt", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
F0("curl_setopt_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE),
|
||||
FN("curl_exec", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
|
||||
FN("curl_exec", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
|
||||
F1("curl_getinfo", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
|
||||
F1("curl_error", MAY_BE_NULL | MAY_BE_STRING),
|
||||
F0("curl_errno", MAY_BE_NULL | MAY_BE_LONG),
|
||||
@@ -1363,7 +1363,7 @@ static const func_info_t func_infos[] = {
|
||||
F0("pg_field_num", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_LONG),
|
||||
F1("pg_fetch_result", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
|
||||
F1("pg_fetch_row", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
|
||||
F1("pg_fetch_assoc", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
|
||||
F1("pg_fetch_assoc", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
|
||||
F1("pg_fetch_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
|
||||
F1("pg_fetch_object", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_OBJECT),
|
||||
F1("pg_fetch_all", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
|
||||
@@ -1445,7 +1445,7 @@ static const func_info_t func_infos[] = {
|
||||
FN("filter_input", UNKNOWN_INFO),
|
||||
FN("filter_var", UNKNOWN_INFO),
|
||||
F1("filter_input_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
|
||||
F1("filter_var_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
|
||||
F1("filter_var_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
|
||||
I1("filter_list", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
|
||||
F0("filter_id", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_LONG),
|
||||
|
||||
|
||||
@@ -1947,6 +1947,18 @@ static void add_usages(const zend_op_array *op_array, zend_ssa *ssa, zend_bitset
|
||||
if (op->op2_def >= 0) {
|
||||
zend_bitset_incl(worklist, op->op2_def);
|
||||
}
|
||||
} else if (use + 1 < op_array->last
|
||||
&& op_array->opcodes[use + 1].opcode == ZEND_OP_DATA) {
|
||||
op++;
|
||||
if (op->result_def >= 0) {
|
||||
zend_bitset_incl(worklist, op->result_def);
|
||||
}
|
||||
if (op->op1_def >= 0) {
|
||||
zend_bitset_incl(worklist, op->op1_def);
|
||||
}
|
||||
if (op->op2_def >= 0) {
|
||||
zend_bitset_incl(worklist, op->op2_def);
|
||||
}
|
||||
}
|
||||
use = zend_ssa_next_use(ssa->ops, var, use);
|
||||
} while (use >= 0);
|
||||
@@ -2141,7 +2153,7 @@ static uint32_t assign_dim_result_type(
|
||||
|
||||
/* For binary ops that have compound assignment operators */
|
||||
static uint32_t binary_op_result_type(
|
||||
zend_ssa *ssa, zend_uchar opcode, uint32_t t1, uint32_t t2, uint32_t result_var,
|
||||
zend_ssa *ssa, zend_uchar opcode, uint32_t t1, uint32_t t2, int result_var,
|
||||
zend_long optimization_level) {
|
||||
uint32_t tmp = 0;
|
||||
uint32_t t1_type = (t1 & MAY_BE_ANY) | (t1 & MAY_BE_UNDEF ? MAY_BE_NULL : 0);
|
||||
@@ -2159,7 +2171,8 @@ static uint32_t binary_op_result_type(
|
||||
switch (opcode) {
|
||||
case ZEND_ADD:
|
||||
if (t1_type == MAY_BE_LONG && t2_type == MAY_BE_LONG) {
|
||||
if (!ssa->var_info[result_var].has_range ||
|
||||
if (result_var < 0 ||
|
||||
!ssa->var_info[result_var].has_range ||
|
||||
ssa->var_info[result_var].range.underflow ||
|
||||
ssa->var_info[result_var].range.overflow) {
|
||||
/* may overflow */
|
||||
@@ -2185,7 +2198,8 @@ static uint32_t binary_op_result_type(
|
||||
case ZEND_SUB:
|
||||
case ZEND_MUL:
|
||||
if (t1_type == MAY_BE_LONG && t2_type == MAY_BE_LONG) {
|
||||
if (!ssa->var_info[result_var].has_range ||
|
||||
if (result_var < 0 ||
|
||||
!ssa->var_info[result_var].has_range ||
|
||||
ssa->var_info[result_var].range.underflow ||
|
||||
ssa->var_info[result_var].range.overflow) {
|
||||
/* may overflow */
|
||||
@@ -2627,7 +2641,8 @@ static int zend_update_type_info(const zend_op_array *op_array,
|
||||
}
|
||||
|
||||
tmp |= binary_op_result_type(
|
||||
ssa, opline->extended_value, t1, t2, ssa_ops[i].op1_def, optimization_level);
|
||||
ssa, opline->extended_value, t1, t2,
|
||||
opline->opcode == ZEND_ASSIGN_OP ? ssa_ops[i].op1_def : -1, optimization_level);
|
||||
if (tmp & (MAY_BE_STRING|MAY_BE_ARRAY)) {
|
||||
tmp |= MAY_BE_RC1;
|
||||
}
|
||||
|
||||
@@ -255,6 +255,14 @@ static void place_essa_pis(
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
/* The following patterns all inspect the opline directly before the JMPZ opcode.
|
||||
* Make sure that it is part of the same block, otherwise it might not be a dominating
|
||||
* assignment. */
|
||||
if (blocks[j].len == 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (opline->op1_type == IS_TMP_VAR &&
|
||||
((opline-1)->opcode == ZEND_IS_EQUAL ||
|
||||
(opline-1)->opcode == ZEND_IS_NOT_EQUAL ||
|
||||
|
||||
@@ -774,14 +774,15 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
|
||||
/* so that other process won't try to force while we are busy cleaning up */
|
||||
ZCSG(force_restart_time) = 0;
|
||||
while (mem_usage_check->l_pid > 0) {
|
||||
/* Clear previous errno, reset success and tries */
|
||||
/* Try SIGTERM first, switch to SIGKILL if not successful. */
|
||||
int signal = SIGTERM;
|
||||
errno = 0;
|
||||
success = 0;
|
||||
tries = 10;
|
||||
|
||||
while (tries--) {
|
||||
zend_accel_error(ACCEL_LOG_WARNING, "Attempting to kill locker %d", mem_usage_check->l_pid);
|
||||
if (kill(mem_usage_check->l_pid, SIGKILL)) {
|
||||
if (kill(mem_usage_check->l_pid, signal)) {
|
||||
if (errno == ESRCH) {
|
||||
/* Process died before the signal was sent */
|
||||
success = 1;
|
||||
@@ -800,6 +801,8 @@ static inline void kill_all_lockers(struct flock *mem_usage_check)
|
||||
break;
|
||||
}
|
||||
usleep(10000);
|
||||
/* If SIGTERM was not sufficient, use SIGKILL. */
|
||||
signal = SIGKILL;
|
||||
}
|
||||
if (!success) {
|
||||
/* errno is not ESRCH or we ran out of tries to kill the locker */
|
||||
|
||||
@@ -80,7 +80,7 @@ void zend_shared_alloc_create_lock(void)
|
||||
{
|
||||
memory_mutex = CreateMutex(NULL, FALSE, create_name_with_username(ACCEL_MUTEX_NAME));
|
||||
if (!memory_mutex) {
|
||||
zend_accel_error(ACCEL_LOG_FATAL, "Cannot create mutex");
|
||||
zend_accel_error(ACCEL_LOG_FATAL, "Cannot create mutex (error %u)", GetLastError());
|
||||
return;
|
||||
}
|
||||
ReleaseMutex(memory_mutex);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Bug #80805: create simple class and get error in opcache.so
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Test {
|
||||
public int $foo;
|
||||
public function __construct()
|
||||
{
|
||||
$this->foo = 2;
|
||||
}
|
||||
public function inc(): int
|
||||
{
|
||||
return $this->foo += 2;
|
||||
}
|
||||
}
|
||||
|
||||
$test = new Test();
|
||||
var_dump($test->foo);
|
||||
$test->inc();
|
||||
var_dump($test->foo);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(2)
|
||||
int(4)
|
||||
@@ -0,0 +1,56 @@
|
||||
--TEST--
|
||||
Bug 80900: Switch constant with incorrect type
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.optimization_level=-1
|
||||
--SKIPIF--
|
||||
<?php require_once('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
function switchLong() {
|
||||
$var = 'foo';
|
||||
/* The number of case clauses needs to be greater than 5,
|
||||
* otherwise it will not be compiled into SWITCH_LONG. */
|
||||
switch ($var) {
|
||||
case 1:
|
||||
echo 'no1';
|
||||
break;
|
||||
case 2:
|
||||
echo 'no2';
|
||||
break;
|
||||
case 3:
|
||||
echo 'no3';
|
||||
break;
|
||||
case 4:
|
||||
echo 'no4';
|
||||
break;
|
||||
case 5:
|
||||
echo 'no5';
|
||||
break;
|
||||
default:
|
||||
echo 'yes';
|
||||
break;
|
||||
}
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
function switchString() {
|
||||
$var = false;
|
||||
switch ($var) {
|
||||
case 'string':
|
||||
echo 'no';
|
||||
break;
|
||||
default:
|
||||
echo 'yes';
|
||||
break;
|
||||
}
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
switchLong();
|
||||
switchString();
|
||||
?>
|
||||
--EXPECT--
|
||||
yes
|
||||
yes
|
||||
@@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Bug #81015: Opcache optimization assumes wrong part of ternary operator in if-condition
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function ternary(bool $enabled, ?string $value): void
|
||||
{
|
||||
// the "true" part is not as trivial in the real case
|
||||
if ($enabled ? true : $value === null) {
|
||||
echo ($value ?? 'NULL') . "\n";
|
||||
} else {
|
||||
echo "INVALID\n";
|
||||
}
|
||||
}
|
||||
|
||||
ternary(true, 'value');
|
||||
ternary(true, null);
|
||||
ternary(false, 'value');
|
||||
ternary(false, null);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
value
|
||||
NULL
|
||||
INVALID
|
||||
NULL
|
||||
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Incorrect DCE of FREE of COALESCE
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function test(?string $str) {
|
||||
$str ?? $str = '';
|
||||
return strlen($str);
|
||||
}
|
||||
|
||||
$foo = 'foo';
|
||||
$foo .= 'bar';
|
||||
var_dump(test($foo));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(6)
|
||||
+26
-26
@@ -1064,6 +1064,17 @@ static inline int php_openssl_config_check_syntax(const char * section_label, co
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static char *php_openssl_conf_get_string(
|
||||
LHASH_OF(CONF_VALUE) *conf, const char *group, const char *name) {
|
||||
char *str = CONF_get_string(conf, group, name);
|
||||
if (str == NULL) {
|
||||
/* OpenSSL reports an error if a configuration value is not found.
|
||||
* However, we don't want to generate errors for optional configuration. */
|
||||
ERR_clear_error();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static int php_openssl_add_oid_section(struct php_x509_request * req) /* {{{ */
|
||||
{
|
||||
char * str;
|
||||
@@ -1071,9 +1082,8 @@ static int php_openssl_add_oid_section(struct php_x509_request * req) /* {{{ */
|
||||
CONF_VALUE * cnf;
|
||||
int i;
|
||||
|
||||
str = CONF_get_string(req->req_config, NULL, "oid_section");
|
||||
str = php_openssl_conf_get_string(req->req_config, NULL, "oid_section");
|
||||
if (str == NULL) {
|
||||
php_openssl_store_errors();
|
||||
return SUCCESS;
|
||||
}
|
||||
sktmp = CONF_get_section(req->req_config, str);
|
||||
@@ -1158,10 +1168,8 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
|
||||
}
|
||||
|
||||
/* read in the oids */
|
||||
str = CONF_get_string(req->req_config, NULL, "oid_file");
|
||||
if (str == NULL) {
|
||||
php_openssl_store_errors();
|
||||
} else if (!php_openssl_open_base_dir_chk(str)) {
|
||||
str = php_openssl_conf_get_string(req->req_config, NULL, "oid_file");
|
||||
if (str != NULL && !php_openssl_open_base_dir_chk(str)) {
|
||||
BIO *oid_bio = BIO_new_file(str, PHP_OPENSSL_BIO_MODE_R(PKCS7_BINARY));
|
||||
if (oid_bio) {
|
||||
OBJ_create_objects(oid_bio);
|
||||
@@ -1173,11 +1181,11 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
|
||||
return FAILURE;
|
||||
}
|
||||
SET_OPTIONAL_STRING_ARG("digest_alg", req->digest_name,
|
||||
CONF_get_string(req->req_config, req->section_name, "default_md"));
|
||||
php_openssl_conf_get_string(req->req_config, req->section_name, "default_md"));
|
||||
SET_OPTIONAL_STRING_ARG("x509_extensions", req->extensions_section,
|
||||
CONF_get_string(req->req_config, req->section_name, "x509_extensions"));
|
||||
php_openssl_conf_get_string(req->req_config, req->section_name, "x509_extensions"));
|
||||
SET_OPTIONAL_STRING_ARG("req_extensions", req->request_extensions_section,
|
||||
CONF_get_string(req->req_config, req->section_name, "req_extensions"));
|
||||
php_openssl_conf_get_string(req->req_config, req->section_name, "req_extensions"));
|
||||
SET_OPTIONAL_LONG_ARG("private_key_bits", req->priv_key_bits,
|
||||
CONF_get_number(req->req_config, req->section_name, "default_bits"));
|
||||
|
||||
@@ -1186,11 +1194,9 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
|
||||
if (optional_args && (item = zend_hash_str_find(Z_ARRVAL_P(optional_args), "encrypt_key", sizeof("encrypt_key")-1)) != NULL) {
|
||||
req->priv_key_encrypt = Z_TYPE_P(item) == IS_TRUE ? 1 : 0;
|
||||
} else {
|
||||
str = CONF_get_string(req->req_config, req->section_name, "encrypt_rsa_key");
|
||||
str = php_openssl_conf_get_string(req->req_config, req->section_name, "encrypt_rsa_key");
|
||||
if (str == NULL) {
|
||||
str = CONF_get_string(req->req_config, req->section_name, "encrypt_key");
|
||||
/* it is sure that there are some errrors as str was NULL for encrypt_rsa_key */
|
||||
php_openssl_store_errors();
|
||||
str = php_openssl_conf_get_string(req->req_config, req->section_name, "encrypt_key");
|
||||
}
|
||||
if (str != NULL && strcmp(str, "no") == 0) {
|
||||
req->priv_key_encrypt = 0;
|
||||
@@ -1218,12 +1224,10 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
|
||||
|
||||
/* digest alg */
|
||||
if (req->digest_name == NULL) {
|
||||
req->digest_name = CONF_get_string(req->req_config, req->section_name, "default_md");
|
||||
req->digest_name = php_openssl_conf_get_string(req->req_config, req->section_name, "default_md");
|
||||
}
|
||||
if (req->digest_name != NULL) {
|
||||
req->digest = req->md_alg = EVP_get_digestbyname(req->digest_name);
|
||||
} else {
|
||||
php_openssl_store_errors();
|
||||
}
|
||||
if (req->md_alg == NULL) {
|
||||
req->md_alg = req->digest = EVP_sha1();
|
||||
@@ -1245,10 +1249,8 @@ static int php_openssl_parse_config(struct php_x509_request * req, zval * option
|
||||
#endif
|
||||
|
||||
/* set the string mask */
|
||||
str = CONF_get_string(req->req_config, req->section_name, "string_mask");
|
||||
if (str == NULL) {
|
||||
php_openssl_store_errors();
|
||||
} else if (!ASN1_STRING_set_default_mask_asc(str)) {
|
||||
str = php_openssl_conf_get_string(req->req_config, req->section_name, "string_mask");
|
||||
if (str != NULL && !ASN1_STRING_set_default_mask_asc(str)) {
|
||||
php_error_docref(NULL, E_WARNING, "Invalid global string mask setting %s", str);
|
||||
return FAILURE;
|
||||
}
|
||||
@@ -3138,9 +3140,8 @@ static int php_openssl_make_REQ(struct php_x509_request * req, X509_REQ * csr, z
|
||||
php_openssl_store_errors();
|
||||
return FAILURE;
|
||||
}
|
||||
attr_sect = CONF_get_string(req->req_config, req->section_name, "attributes");
|
||||
attr_sect = php_openssl_conf_get_string(req->req_config, req->section_name, "attributes");
|
||||
if (attr_sect == NULL) {
|
||||
php_openssl_store_errors();
|
||||
attr_sk = NULL;
|
||||
} else {
|
||||
attr_sk = CONF_get_section(req->req_config, attr_sect);
|
||||
@@ -3994,10 +3995,7 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req
|
||||
return NULL;
|
||||
}
|
||||
|
||||
randfile = CONF_get_string(req->req_config, req->section_name, "RANDFILE");
|
||||
if (randfile == NULL) {
|
||||
php_openssl_store_errors();
|
||||
}
|
||||
randfile = php_openssl_conf_get_string(req->req_config, req->section_name, "RANDFILE");
|
||||
php_openssl_load_rand_file(randfile, &egdsocket, &seeded);
|
||||
|
||||
if ((req->priv_key = EVP_PKEY_new()) != NULL) {
|
||||
@@ -4021,6 +4019,8 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req
|
||||
PHP_OPENSSL_RAND_ADD_TIME();
|
||||
if (rsaparam == NULL || !RSA_generate_key_ex(rsaparam, req->priv_key_bits, bne, NULL)) {
|
||||
php_openssl_store_errors();
|
||||
RSA_free(rsaparam);
|
||||
rsaparam = NULL;
|
||||
}
|
||||
BN_free(bne);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,51 @@ Bug #62890 (default_socket_timeout=-1 causes connection to timeout)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('openssl')) die('skip openssl extension not available');
|
||||
if (getenv('SKIP_ONLINE_TESTS')) die('skip online test');
|
||||
if (!function_exists("proc_open")) die("skip no proc_open");
|
||||
?>
|
||||
--INI--
|
||||
default_socket_timeout=-1
|
||||
--FILE--
|
||||
<?php
|
||||
$clientCtx = stream_context_create(['ssl' => ['verify_peer' => false]]);
|
||||
var_dump((bool) file_get_contents('https://www.php.net', false, $clientCtx));
|
||||
$certFile = __DIR__ . DIRECTORY_SEPARATOR . 'bug62890.pem.tmp';
|
||||
|
||||
$serverCode = <<<'CODE'
|
||||
$flags = STREAM_SERVER_BIND|STREAM_SERVER_LISTEN;
|
||||
$ctx = stream_context_create(['ssl' => [
|
||||
'local_cert' => '%s',
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
$server = stream_socket_server('tls://127.0.0.1:64321', $errno, $errstr, $flags, $ctx);
|
||||
phpt_notify();
|
||||
@stream_socket_accept($server, 3);
|
||||
CODE;
|
||||
$serverCode = sprintf($serverCode, $certFile);
|
||||
|
||||
$clientCode = <<<'CODE'
|
||||
$flags = STREAM_CLIENT_CONNECT;
|
||||
$ctx = stream_context_create(['ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
phpt_wait();
|
||||
|
||||
$client = stream_socket_client("tls://127.0.0.1:64321", $errno, $errstr, 3, $flags, $ctx);
|
||||
var_dump($client);
|
||||
CODE;
|
||||
|
||||
include 'CertificateGenerator.inc';
|
||||
$certificateGenerator = new CertificateGenerator();
|
||||
$certificateGenerator->saveNewCertAsFileWithKey('bug62890', $certFile);
|
||||
|
||||
include 'ServerClientTestCase.inc';
|
||||
ServerClientTestCase::getInstance()->run($clientCode, $serverCode);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'bug62890.pem.tmp');
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(%d) of type (stream)
|
||||
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
Bug #80747: Providing RSA key size < 512 generates key that crash PHP
|
||||
--FILE--
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("openssl")) die("skip openssl not loaded");
|
||||
if (OPENSSL_VERSION_NUMBER < 0x10100000) die("skip OpenSSL >= v1.1.0 required");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$conf = array(
|
||||
'config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf',
|
||||
'private_key_bits' => 511,
|
||||
);
|
||||
var_dump(openssl_pkey_new($conf));
|
||||
while ($e = openssl_error_string()) {
|
||||
echo $e, "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(false)
|
||||
error:%s:key size too small
|
||||
@@ -14,7 +14,8 @@ $serverCode = <<<'CODE'
|
||||
$serverUri = "ssl://127.0.0.1:64321";
|
||||
$serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
|
||||
$serverCtx = stream_context_create(['ssl' => [
|
||||
'local_cert' => '%s'
|
||||
'local_cert' => '%s',
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
$server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
|
||||
@@ -36,6 +37,7 @@ $clientCode = <<<'CODE'
|
||||
'cafile' => '%s',
|
||||
'peer_name' => '%s',
|
||||
'capture_session_meta' => true,
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
phpt_wait();
|
||||
|
||||
@@ -14,7 +14,8 @@ $serverCode = <<<'CODE'
|
||||
$serverUri = "ssl://127.0.0.1:64321";
|
||||
$serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
|
||||
$serverCtx = stream_context_create(['ssl' => [
|
||||
'local_cert' => '%s'
|
||||
'local_cert' => '%s',
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
$server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
|
||||
@@ -34,6 +35,7 @@ $clientCode = <<<'CODE'
|
||||
'verify_peer' => true,
|
||||
'cafile' => '%s',
|
||||
'peer_name' => '%s',
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
phpt_wait();
|
||||
|
||||
@@ -14,7 +14,8 @@ $serverCode = <<<'CODE'
|
||||
$serverUri = "ssl://127.0.0.1:64321";
|
||||
$serverFlags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
|
||||
$serverCtx = stream_context_create(['ssl' => [
|
||||
'local_cert' => '%s'
|
||||
'local_cert' => '%s',
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
$server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
|
||||
@@ -35,6 +36,7 @@ $clientCode = <<<'CODE'
|
||||
'verify_peer' => true,
|
||||
'cafile' => '%s',
|
||||
'peer_name' => '%s',
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
phpt_wait();
|
||||
|
||||
@@ -17,8 +17,9 @@ $serverCode = <<<'CODE'
|
||||
$serverCtx = stream_context_create(['ssl' => [
|
||||
'local_cert' => '%s',
|
||||
|
||||
// Only accept TLSv1.2 connections
|
||||
// Only accept TLSv1.0 and TLSv1.2 connections
|
||||
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_0_SERVER | STREAM_CRYPTO_METHOD_TLSv1_2_SERVER,
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
$server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
|
||||
@@ -39,6 +40,7 @@ $clientCode = <<<'CODE'
|
||||
'verify_peer' => true,
|
||||
'cafile' => '%s',
|
||||
'peer_name' => '%s',
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
phpt_wait();
|
||||
|
||||
@@ -16,6 +16,7 @@ $serverCode = <<<'CODE'
|
||||
$serverCtx = stream_context_create(['ssl' => [
|
||||
'local_cert' => '%s',
|
||||
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_0_SERVER,
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
$server = stream_socket_server($serverUri, $errno, $errstr, $serverFlags, $serverCtx);
|
||||
@@ -36,6 +37,7 @@ $clientCode = <<<'CODE'
|
||||
'verify_peer' => true,
|
||||
'cafile' => '%s',
|
||||
'peer_name' => '%s',
|
||||
'security_level' => 1,
|
||||
]]);
|
||||
|
||||
phpt_wait();
|
||||
|
||||
+3
-2
@@ -955,7 +955,7 @@ PHP_FUNCTION(pcntl_exec)
|
||||
int envc = 0, envi = 0;
|
||||
char **argv = NULL, **envp = NULL;
|
||||
char **current_arg, **pair;
|
||||
int pair_length;
|
||||
size_t pair_length;
|
||||
zend_string *key;
|
||||
char *path;
|
||||
size_t path_len;
|
||||
@@ -1015,8 +1015,9 @@ PHP_FUNCTION(pcntl_exec)
|
||||
}
|
||||
|
||||
/* Length of element + equal sign + length of key + null */
|
||||
ZEND_ASSERT(Z_STRLEN_P(element) < SIZE_MAX && ZSTR_LEN(key) < SIZE_MAX);
|
||||
*pair = safe_emalloc(Z_STRLEN_P(element) + 1, sizeof(char), ZSTR_LEN(key) + 1);
|
||||
pair_length = Z_STRLEN_P(element) + ZSTR_LEN(key) + 2;
|
||||
*pair = emalloc(pair_length);
|
||||
strlcpy(*pair, ZSTR_VAL(key), ZSTR_LEN(key) + 1);
|
||||
strlcat(*pair, "=", pair_length);
|
||||
strlcat(*pair, Z_STRVAL_P(element), pair_length);
|
||||
|
||||
@@ -9,6 +9,9 @@ pcntl: SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
// Clear mask
|
||||
pcntl_sigprocmask(SIG_SETMASK, array(), $prev);
|
||||
|
||||
pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD,SIGTERM), $old);
|
||||
var_dump(count($old));
|
||||
pcntl_sigprocmask(SIG_BLOCK, array(SIGINT), $old);
|
||||
@@ -19,7 +22,9 @@ pcntl_sigprocmask(SIG_SETMASK, array(SIGINT), $old);
|
||||
var_dump(count($old));
|
||||
pcntl_sigprocmask(SIG_SETMASK, array(), $old);
|
||||
var_dump(count($old));
|
||||
pcntl_sigprocmask(SIG_SETMASK, array(), $old);
|
||||
|
||||
// Restore previous mask
|
||||
pcntl_sigprocmask(SIG_SETMASK, $prev, $old);
|
||||
var_dump(count($old));
|
||||
|
||||
?>
|
||||
|
||||
+5
-1
@@ -767,8 +767,8 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
|
||||
zend_hash_add_ptr(&char_tables, _k, (void *)tables);
|
||||
zend_string_release(_k);
|
||||
}
|
||||
pcre2_set_character_tables(cctx, tables);
|
||||
}
|
||||
pcre2_set_character_tables(cctx, tables);
|
||||
|
||||
/* Set extra options for the compile context. */
|
||||
if (PHP_PCRE_DEFAULT_EXTRA_COPTIONS != extra_coptions) {
|
||||
@@ -2644,6 +2644,10 @@ matched:
|
||||
the match again at the same point. If this fails (picked up above) we
|
||||
advance to the next character. */
|
||||
if (start_offset == offsets[0]) {
|
||||
/* Get next piece if no limit or limit not yet reached and something matched*/
|
||||
if (limit_val != -1 && limit_val <= 1) {
|
||||
break;
|
||||
}
|
||||
count = pcre2_match(pce->re, (PCRE2_SPTR)subject, ZSTR_LEN(subject_str), start_offset,
|
||||
PCRE2_NO_UTF_CHECK | PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED, match_data, mctx);
|
||||
if (count >= 0) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Bug #80866 preg_split ignores limit flag when pattern with \K has 0-width fullstring match
|
||||
--FILE--
|
||||
<?php
|
||||
var_export(preg_split('~.{3}\K~', 'abcdefghijklm', 3));
|
||||
?>
|
||||
--EXPECT--
|
||||
array (
|
||||
0 => 'abc',
|
||||
1 => 'def',
|
||||
2 => 'ghijklm',
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Changing LC_CTYPE back to C
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!setlocale(LC_CTYPE, "de_DE", "de-DE")) die("skip requires de_DE locale");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(setlocale(LC_CTYPE, "de_DE", "de-DE") !== false);
|
||||
var_dump(preg_match('/\w/', "\xe4"));
|
||||
var_dump(setlocale(LC_CTYPE, "C") !== false);
|
||||
var_dump(preg_match('/\w/', "\xe4"));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
int(1)
|
||||
bool(true)
|
||||
int(0)
|
||||
@@ -0,0 +1 @@
|
||||
firebird
|
||||
@@ -2,6 +2,8 @@
|
||||
Bug #47415 PDO_Firebird segfaults when passing lowercased column name to bindColumn()
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require 'testdb.inc';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: bug 48877 The "bindValue" and "bindParam" do not work for PDO Firebird if we use named parameters (:parameter).
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: bug 53280 segfaults if query column count is less than param count
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Bug #62024 Cannot insert second row with null using parametrized query (Firebird PDO)
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Bug #64037 Firebird return wrong value for numeric field
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: Feature 72583 Fetch integers as php integers not as strings
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require 'testdb.inc';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: Bug 72931 Insert returning fails on Firebird 3
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require 'testdb.inc';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: bug 73087 segfault binding blob parameter
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require 'testdb.inc';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: Bug #74462 Returns only NULLs for boolean fields
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require 'testdb.inc';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: Bug #76488 Memory leak when fetching a BLOB field
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require 'testdb.inc';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: Bug #76488 PDO Firebird does not support boolean datatype in input parameters
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: cursor should not be marked as opened on singleton statements
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require 'testdb.inc';
|
||||
|
||||
@@ -7,6 +7,7 @@ if (!extension_loaded('pdo_firebird')) print 'skip'; ?>
|
||||
# magic auto-configuration
|
||||
|
||||
$config = array(
|
||||
'ENV' => ['LSAN_OPTIONS' => 'detect_leaks=0'],
|
||||
'TESTS' => 'ext/pdo/tests'
|
||||
);
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: connect/disconnect
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require("testdb.inc");
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: DDL/transactions
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ if (strpos(getenv('PDO_FIREBIRD_TEST_DSN'), 'dialect=1')===false) {
|
||||
die('skip: PDO_FIREBIRD_TEST_DSN must contain a string "dialect=1"');
|
||||
}
|
||||
?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require("testdb.inc");
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
PDO_Firebird: prepare/execute/binding
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require("testdb.inc");
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
function run_server(string $payloadFile): string {
|
||||
$cmd = [getenv("TEST_PHP_EXECUTABLE"), "-n", __DIR__ . "/payload_server.php", $payloadFile];
|
||||
$descriptorspec = array(
|
||||
0 => STDIN,
|
||||
1 => STDOUT,
|
||||
2 => ['pipe', 'w'],
|
||||
);
|
||||
$proc = proc_open($cmd, $descriptorspec, $pipes);
|
||||
|
||||
// First, wait for the payload server to declare itself ready.
|
||||
$bound = null;
|
||||
stream_set_blocking($pipes[2], false);
|
||||
for ($i = 0; $i < 60; $i++) {
|
||||
usleep(50000); // 50ms per try
|
||||
$status = proc_get_status($proc);
|
||||
if (empty($status['running'])) {
|
||||
echo "Server is not running\n";
|
||||
proc_terminate($proc);
|
||||
exit(1);
|
||||
}
|
||||
while (($line = fgets($pipes[2])) !== false) {
|
||||
if (preg_match('/FB payload server listening on (.+)/', $line, $matches)) {
|
||||
$bound = $matches[1];
|
||||
// Now that we've identified the listen address, close STDERR.
|
||||
// Otherwise the pipe may clog up with unread log messages.
|
||||
fclose($pipes[2]);
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($bound === null) {
|
||||
echo "Server did not output startup message";
|
||||
proc_terminate($proc);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Now wait for a connection to succeed.
|
||||
// note: even when server prints 'FB payload server listening on localhost:12345'
|
||||
// it might not be listening yet...need to wait until fsockopen() call returns
|
||||
$error = "Unable to connect to server\n";
|
||||
for ($i=0; $i < 60; $i++) {
|
||||
usleep(50000); // 50ms per try
|
||||
$status = proc_get_status($proc);
|
||||
$fp = fsockopen("tcp://$bound");
|
||||
// Failure, the server is no longer running
|
||||
if (!($status && $status['running'])) {
|
||||
$error = "Server is not running\n";
|
||||
break;
|
||||
}
|
||||
// Success, Connected to servers
|
||||
if ($fp) {
|
||||
$error = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fp) {
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
echo $error;
|
||||
proc_terminate($proc);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
register_shutdown_function(
|
||||
function($proc) {
|
||||
proc_terminate($proc);
|
||||
/* Wait for server to shutdown */
|
||||
for ($i = 0; $i < 60; $i++) {
|
||||
$status = proc_get_status($proc);
|
||||
if (!($status && $status['running'])) {
|
||||
break;
|
||||
}
|
||||
usleep(50000);
|
||||
}
|
||||
},
|
||||
$proc
|
||||
);
|
||||
|
||||
return $bound;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
$socket = stream_socket_server("tcp://localhost:0", $errno, $errstr);
|
||||
if (!$socket) {
|
||||
echo "Can't start server: $errstr ($errno)\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$filename = $argv[1];
|
||||
$payload = file_get_contents($filename);
|
||||
if ($payload === false) {
|
||||
echo "Can't read $filename\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fputs(STDERR, "FB payload server listening on " . stream_socket_get_name($socket, false) . "\n");
|
||||
|
||||
while ($conn = stream_socket_accept($socket)) {
|
||||
fwrite($conn, $payload);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
FB payload server satisfies connection attempt
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('pdo_firebird')) die("skip pdo_firebird extension not available");
|
||||
if (!extension_loaded('sockets')) die("skip sockets extension not available");
|
||||
?>
|
||||
--ENV--
|
||||
LSAN_OPTIONS=detect_leaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
require_once "payload_server.inc";
|
||||
|
||||
$address = run_server(__DIR__ . "/payload_test.data");
|
||||
|
||||
// no need to change the credentials; we're running against a fake server
|
||||
$dsn = "firebird:dbname=inet://$address/test";
|
||||
$username = 'SYSDBA';
|
||||
$password = 'masterkey';
|
||||
|
||||
new PDO($dsn, $username, $password, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
|
||||
?>
|
||||
--EXPECT--
|
||||
Loaded 100 of 179 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user