Compare commits

..
17 Commits
Author SHA1 Message Date
Ferenc Kovacs 7603abbc51 66550 will be part of 5.6.8 2015-04-15 20:05:57 +02:00
Ferenc Kovacs 4ae24d9250 remove the NEWS entry for the reverted feature 2015-04-15 19:48:13 +02:00
Xinchen Hui bf393c89d8 Fixed res leak 2015-04-15 19:43:40 +02:00
Dmitry Stogov f251b16fcc Fixed recently introduced memory leak 2015-04-15 19:43:27 +02:00
Stanislav Malyshev 5904e1e55e Revert "Merge branch 'PHP-5.5' into PHP-5.6"
This reverts commit aa22e80b1a, reversing
changes made to 3e7f47cb03.

Conflicts:
	ext/date/php_date.c
2015-04-15 19:35:18 +02:00
Stanislav Malyshev bef6df6a7e Fix bug #66550 (SQLite prepared statement use-after-free) 2015-04-15 19:32:57 +02:00
Anatol Belski c3771929b7 fix dir separator in test 2015-04-15 19:18:33 +02:00
Remi Collet 7dce9533e7 fix type in fix for #69085
(cherry picked from commit 085e9ddc26f37ce556b8fd787044746e726264b2)
2015-04-15 18:57:39 +02:00
Ferenc Kovacs 8c3093d660 add missing NEWS entry 2015-04-15 18:54:20 +02:00
Ferenc Kovacs 3592dce76d update NEWS 2015-04-15 18:34:17 +02:00
Ferenc Kovacs 6922659b8b update NEWS 2015-04-15 18:31:37 +02:00
Ferenc Kovacs f44cd92cd2 5.6.8 2015-04-15 18:31:12 +02:00
Stanislav Malyshev dc87efa848 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: (27 commits)
  fix non-standard C
  update NEWS
  5.4.41 next
  fix CVE num
  update NEWS
  Fix bug #69441 (Buffer Overflow when parsing tar/zip/phar in phar_set_inode)
  fix test
  fix type in fix for #69085
  fix memory leak & add test
  Fix tests
  fix CVE num
  Fix bug #69337 (php_stream_url_wrap_http_ex() type-confusion vulnerability)
  Fix test
  Additional fix for bug #69324
  More fixes for bug #69152
  Fixed bug #69353 (Missing null byte checks for paths in various PHP extensions)
  Fixed bug #69324 (Buffer Over-read in unserialize when parsing Phar)
  Fixed bug #69316 (Use-after-free in php_curl related to CURLOPT_FILE/_INFILE/_WRITEHEADER)
  Fix bug #68486 and bug #69218 (segfault in apache2handler with apache 2.4)
  Fix bug #68819 (Fileinfo on specific file causes spurious OOM and/or segfault)
  ...

Conflicts:
	ext/standard/http_fopen_wrapper.c
2015-04-15 18:20:03 +02:00
Ferenc Kovacs 6787bfc37d add missing NEWS entry 2015-04-15 18:19:41 +02:00
Ferenc Kovacs bce433e422 update NEWS 2015-04-03 09:29:34 +02:00
Danack e0e19a12be Fixed bug #69281 (opcache_is_script_cached no longer works) 2015-04-03 09:27:48 +02:00
Ferenc Kovacs a6601cb692 5.6.8RC1 2015-04-01 01:41:15 +02:00
335 changed files with 25046 additions and 104645 deletions

No files matched your search

-5
View File
@@ -3,11 +3,6 @@ language: c
notifications:
email:
on_failure: change
irc:
channels:
- "irc.efnet.org#php.pecl"
on_success: change
on_failure: always
cache:
- apt
+6 -171
View File
@@ -1,164 +1,5 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
10 Jul 2015, PHP 5.6.11
- Core:
. Fixed bug #69768 (escapeshell*() doesn't cater to !). (cmb)
. Fixed bug #69703 (Use __builtin_clzl on PowerPC).
(dja at axtens dot net, Kalle)
. Fixed bug #69732 (can induce segmentation fault with basic php code).
(Dmitry)
. Fixed bug #69642 (Windows 10 reported as Windows 8).
(Christian Wenz, Anatol Belski)
. Fixed bug #69551 (parse_ini_file() and parse_ini_string() segmentation
fault). (Christoph M. Becker)
. Fixed bug #69781 (phpinfo() reports Professional Editions of Windows
7/8/8.1/10 as "Business"). (Christian Wenz)
. Fixed bug #69740 (finally in generator (yield) swallows exception in
iteration). (Nikita)
. Fixed bug #69835 (phpinfo() does not report many Windows SKUs).
(Christian Wenz)
. Fixed bug #69892 (Different arrays compare indentical due to integer key
truncation). (Nikita)
. Fixed bug #69874 (Can't set empty additional_headers for mail()), regression
from fix to bug #68776. (Yasuo)
- GD:
. Fixed bug #61221 (imagegammacorrect function loses alpha channel). (cmb)
- GMP:
. Fixed bug #69803 (gmp_random_range() modifies second parameter if GMP
number). (Nikita)
- PCRE:
. Fixed Bug #53823 (preg_replace: * qualifier on unicode replace garbles the
string). (cmb)
. Fixed bug #69864 (Segfault in preg_replace_callback) (cmb, ab)
- PDO_pgsql:
. Fixed bug #69752 (PDOStatement::execute() leaks memory with DML
Statements when closeCuror() is u). (Philip Hofstetter)
. Fixed bug #69362 (PDO-pgsql fails to connect if password contains a
leading single quote). (Matteo)
. Fixed bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps).
(Matteo)
- SimpleXML:
. Refactored the fix for bug #66084 (simplexml_load_string() mangles empty
node name). (Christoph Michael Becker)
- SPL:
. Fixed bug #69737 (Segfault when SplMinHeap::compare produces fatal error).
(Stas)
. Fixed bug #67805 (SplFileObject setMaxLineLength). (Willian Gustavo Veiga).
. Fixed bug #69970 (Use-after-free vulnerability in
spl_recursive_it_move_forward_ex()). (Laruence)
- Sqlite3:
. Fixed bug #69972 (Use-after-free vulnerability in
sqlite3SafetyCheckSickOrOk()). (Laruence)
11 Jun 2015, PHP 5.6.10
- Core:
. Fixed bug #66048 (temp. directory is cached during multiple requests).
(Julien)
. Fixed bug #69566 (Conditional jump or move depends on uninitialised value
in extension trait). (jbboehr at gmail dot com)
. Fixed bug #69599 (Strange generator+exception+variadic crash). (Nikita)
. Fixed bug #69628 (complex GLOB_BRACE fails on Windows).
(Christoph M. Becker)
. Fixed POST data processing slowdown due to small input buffer size
on Windows. (Jorge Oliveira, Anatol)
. Fixed bug #69646 (OS command injection vulnerability in escapeshellarg).
(CVE-2015-4642) (Anatol Belski)
. Fixed bug #69719 (Incorrect handling of paths with NULs). (Stas)
- FTP
. Improved fix for bug #69545 (Integer overflow in ftp_genlist() resulting in
heap overflow). (CVE-2015-4643) (Max Spelsberg)
- GD:
. Fixed bug #69479 (GD fails to build with newer libvpx). (Remi)
- Iconv:
. Fixed bug #48147 (iconv with //IGNORE cuts the string). (Stas)
- Litespeed SAPI:
. Fixed bug #68812 (Unchecked return value). (George Wang)
- Mail:
. Fixed bug #68776 (mail() does not have mail header injection prevention for
additional headers). (Yasuo)
- MCrypt:
. Added file descriptor caching to mcrypt_create_iv() (Leigh)
- Opcache
. Fixed bug #69549 (Memory leak with opcache.optimization_level=0xFFFFFFFF).
(Laruence, Dmitry)
- PCRE
. Upgraded pcrelib to 8.37. (CVE-2015-2325, CVE-2015-2326)
- Phar:
. Fixed bug #69680 (phar symlink in binary directory broken).
(Matteo Bernardini, Remi)
- Postgres:
. Fixed bug #69667 (segfault in php_pgsql_meta_data). (CVE-2015-4644) (Remi)
- Sqlite3:
. Upgrade bundled sqlite to 3.8.10.2. (CVE-2015-3414, CVE-2015-3415,
CVE-2015-3416) (Kaplan)
14 May 2015, PHP 5.6.9
- Core:
. Fixed bug #69467 (Wrong checked for the interface by using Trait).
(Laruence)
. Fixed bug #69420 (Invalid read in zend_std_get_method). (Laruence)
. Fixed bug #60022 ("use statement [...] has no effect" depends on leading
backslash). (Nikita)
. Fixed bug #67314 (Segmentation fault in gc_remove_zval_from_buffer).
(Dmitry)
. Fixed bug #68652 (segmentation fault in destructor). (Dmitry)
. Fixed bug #69419 (Returning compatible sub generator produces a warning).
(Nikita)
. Fixed bug #69472 (php_sys_readlink ignores misc errors from
GetFinalPathNameByHandleA). (Jan Starke)
. Fixed bug #69364 (PHP Multipart/form-data remote dos Vulnerability).
(CVE-2015-4024) (Stas)
. Fixed bug #69403 (str_repeat() sign mismatch based memory corruption).
(Stas)
. Fixed bug #69418 (CVE-2006-7243 fix regressions in 5.4+). (CVE-2015-4025)
(Stas)
. Fixed bug #69522 (heap buffer overflow in unpack()). (Stas)
- FTP:
. Fixed bug #69545 (Integer overflow in ftp_genlist() resulting in heap
overflow). (CVE-2015-4022) (Stas)
- ODBC:
. Fixed bug #69354 (Incorrect use of SQLColAttributes with ODBC 3.0).
(Anatol)
. Fixed bug #69474 (ODBC: Query with same field name from two tables returns
incorrect result). (Anatol)
. Fixed bug #69381 (out of memory with sage odbc driver). (Frederic Marchall,
Anatol Belski)
- OpenSSL:
. Fixed bug #69402 (Reading empty SSL stream hangs until timeout).
(Daniel Lowrey)
- PCNTL:
. Fixed bug #68598 (pcntl_exec() should not allow null char). (CVE-2015-4026)
(Stas)
- Phar:
. Fixed bug #69453 (Memory Corruption in phar_parse_tarfile when entry
filename starts with null). (CVE-2015-4021) (Stas)
16 Apr 2015, PHP 5.6.8
- Core:
@@ -207,22 +48,18 @@ PHP NEWS
segfault). (Anatol Belski)
- Filter:
. Fixed bug #69202 (FILTER_FLAG_STRIP_BACKTICK ignored unless other
. Fixed bug #69202: (FILTER_FLAG_STRIP_BACKTICK ignored unless other
flags are used). (Jeff Welch)
. Fixed bug #69203 (FILTER_FLAG_STRIP_HIGH doesn't strip ASCII 127). (Jeff
Welch)
- Mbstring:
. Fixed bug #68846 (False detection of CJK Unified Ideographs Extension E).
(Masaki Kagaya)
- OPCache:
. Fixed bug #69297 (function_exists strange behavior with OPCache on
disabled function). (Laruence)
. Fixed bug #69281 (opcache_is_script_cached no longer works). (danack)
. Fixed bug #68677 (Use After Free). (CVE-2015-1351) (Laruence)
- OpenSSL:
- OpenSSL
. Fixed bugs #68853, #65137 (Buffered crypto stream data breaks IO polling
in stream_select() contexts) (Chris Wright)
. Fixed bug #69197 (openssl_pkcs7_sign handles default value incorrectly)
@@ -245,16 +82,14 @@ PHP NEWS
- Postgres:
. Fixed bug #68741 (Null pointer dereference). (CVE-2015-1352) (Laruence)
- SOAP:
. Fixed bug #69152 (Type Confusion Infoleak Vulnerability in unserialize()
with SoapFault). (Dmitry)
. Fixed bug #69293 (NEW segfault when using SoapClient::__setSoapHeader
(bisected, regression)). (Laruence)
- SPL:
. Fixed bug #69227 (Use after free in zval_scan caused by
spl_object_storage_get_gc). (adam dot scarr at 99designs dot com)
- SOAP:
. Fixed bug #69293 (NEW segfault when using SoapClient::__setSoapHeader
(bisected, regression)). (Laruence)
- Sqlite3:
. Fixed bug #68760 (SQLITE segfaults if custom collator throws an exception).
(Dan Ackroyd)
+4 -14
View File
@@ -213,14 +213,12 @@ Getting the stable release announced
c. ``$PHP_X_MD5`` array and update all the md5 sums
d. ``$PHP_X_SHA256`` array and update all the SHA256 sums
d. set ``$PHP_X_RC`` to false!
e. set ``$PHP_X_RC`` to false!
f. Make sure there are no outdated "notes" or edited "date" keys in the
e. Make sure there are no outdated "notes" or edited "date" keys in the
``$RELEASES[X][$PHP_X_VERSION]["source"]`` array
g. if the windows builds aren't ready yet prefix the "windows" key with a dot (".windows")
f. if the windows builds aren't ready yet prefix the "windows" key with a dot (".windows")
3. Create the release file (releases/x_y_z.php)
Usually we use the same content as for point 6, but included in php template
@@ -269,9 +267,6 @@ to upgrade.
9. Wait an hour or two, then send a mail to php-announce@lists.php.net,
php-general@lists.php.net and internals@lists.php.net with a text similar to
http://news.php.net/php.internals/17222.
Please make sure that the mail to php-announce@ is its own completely seperate email.
This is to make sure that repiles to the announcement on php-general@ or internals@
will not accidentally hit the php-announce@ mailinglist.
Re-releasing the same version (or -pl)
--------------------------------------
@@ -288,9 +283,7 @@ Re-releasing the same version (or -pl)
d. ``$PHP_X_MD5`` array and update all the md5 sums
e. ``$PHP_X_SHA256`` array and update all the SHA256 sums
f. Make sure there are no outdated "notes" or edited "date" keys in the
e. Make sure there are no outdated "notes" or edited "date" keys in the
``$RELEASES[X][$PHP_X_VERSION]["source"]`` array
3. Add a short notice to phpweb stating that there is a new release, and
@@ -307,6 +300,3 @@ to upgrade.
5. Wait an hour or two, then send a mail to php-announce@lists.php.net,
php-general@lists.php.net and internals@lists.php.net with a text similar to
the news entry.
Please make sure that the mail to php-announce@ is its own completely seperate email.
This is to make sure that repiles to the announcement on php-general@ or internals@
will not accidentally hit the php-announce@ mailinglist.
+1 -1
View File
@@ -1,5 +1,5 @@
--TEST--
Bug #43201 (Crash on using uninitialized vals and __get/__set)
Bug #43201 (Crash on using unitialized vals and __get/__set)
--FILE--
<?php
class Foo {
+5 -3
View File
@@ -1,5 +1,7 @@
--TEST--
Bug #63336 (invalid E_NOTICE error occur)
--XFAIL--
Bug is not fixed yet
--FILE--
<?php
error_reporting(E_ALL | E_NOTICE );
@@ -16,7 +18,7 @@ class Child extends Base {
public function bar($var, $more=self::DUMMY) { return true; }
}
?>
--EXPECTF--
Strict Standards: Declaration of Child::foo() should be compatible with Base::foo($var = TEST, $more = NULL) in %sbug63336.php on line %d
--EXPECT--
Strict Standards: Declaration of Child::foo() should be compatible with Base::foo($var = '123', $more = NULL) in %sbug63336.php on line %d
Strict Standards: Declaration of Child::bar() should be compatible with Base::bar($more = self::DUMMY) in %sbug63336.php on line %d
Strict Standards: Declaration of Child::bar() should be compatible with Base::bar($var, $more = 'XXX') in %sbug63336.php on line %d
-22
View File
@@ -1,22 +0,0 @@
--TEST--
Bug #67314 (Segmentation fault in gc_remove_zval_from_buffer)
--FILE--
<?php
function crash()
{
$notDefined[$i] = 'test';
}
function error_handler() { return false; }
set_error_handler('error_handler');
crash();
echo "made it once\n";
crash();
echo "ok\n";
--EXPECTF--
Notice: Undefined variable: i in %sbug67314.php on line 4
made it once
Notice: Undefined variable: i in %sbug67314.php on line 4
ok
-40
View File
@@ -1,40 +0,0 @@
--TEST--
Bug #68652 (segmentation fault in destructor)
--FILE--
<?php
class Foo {
private static $instance;
public static function getInstance() {
if (isset(self::$instance)) {
return self::$instance;
}
return self::$instance = new self();
}
public function __destruct() {
Bar::getInstance();
}
}
class Bar {
private static $instance;
public static function getInstance() {
if (isset(self::$instance)) {
return self::$instance;
}
return self::$instance = new self();
}
public function __destruct() {
Foo::getInstance();
}
}
$foo = new Foo();
?>
--EXPECTF--
Fatal error: Access to undeclared static property: Bar::$instance in %sbug68652.php on line %d
-30
View File
@@ -1,30 +0,0 @@
--TEST--
Bug #69420 (Invalid read in zend_std_get_method)
--FILE--
<?php
trait T {
protected function test() {
echo "okey";
}
}
class A {
protected function test() {
}
}
class B extends A {
use T;
public function foo() {
$this->test();
}
}
$b = new B();
$b->foo();
?>
--EXPECT--
okey
-21
View File
@@ -1,21 +0,0 @@
--TEST--
Bug #69467 (Wrong checked for the interface by using Trait)
--FILE--
<?php
interface Baz {
public function bad();
}
trait Bar{
protected function bad(){}
}
class Foo implements Baz{
use Bar;
}
$test = new Foo();
var_dump($test instanceof Baz);
?>
--EXPECTF--
Fatal error: Access level to Bar::bad() must be public (as in class Baz) in %sbug69467.php on line %d
-16
View File
@@ -1,16 +0,0 @@
--TEST--
Bug #69551 - parse_ini_file() and parse_ini_string() segmentation fault
--FILE--
<?php
$ini = <<<INI
[Network.eth0]
SubnetMask = "
"
INI;
$settings = parse_ini_string($ini, false, INI_SCANNER_RAW);
var_dump($settings);
?>
--EXPECTF--
Warning: syntax error, unexpected '"' in Unknown on line %d
in %s on line %d
bool(false)
-21
View File
@@ -1,21 +0,0 @@
--TEST--
Bug #69599: Strange generator+exception+variadic crash
--FILE--
<?php
function crash() {
sin(...[0]);
throw new \Exception();
yield;
}
iterator_to_array(crash());
?>
--EXPECTF--
Fatal error: Uncaught exception 'Exception' in %s:%d
Stack trace:
#0 [internal function]: crash()
#1 %s(%d): iterator_to_array(Object(Generator))
#2 {main}
thrown in %s on line %d
-30
View File
@@ -1,30 +0,0 @@
--TEST--
Bug #69732 (can induce segmentation fault with basic php code)
--FILE--
<?php
class wpq {
private $unreferenced;
public function __get($name) {
return $this->$name . "XXX";
}
}
function ret_assoc() {
$x = "XXX";
return array('foo' => 'bar', $x);
}
$wpq = new wpq;
$wpq->interesting =& ret_assoc();
$x = $wpq->interesting;
printf("%s\n", $x);
--EXPECTF--
Notice: Undefined property: wpq::$interesting in %sbug69732.php on line 6
Notice: Indirect modification of overloaded property wpq::$interesting has no effect in %sbug69732.php on line 16
Strict Standards: Only variables should be assigned by reference in %sbug69732.php on line 16
Notice: Undefined property: wpq::$interesting in %sbug69732.php on line 6
XXX
-28
View File
@@ -1,28 +0,0 @@
--TEST--
Bug #69740: finally in generator (yield) swallows exception in iteration
--FILE--
<?php
function generate() {
try {
yield 1;
yield 2;
} finally {
echo "finally\n";
}
}
foreach (generate() as $i) {
echo $i, "\n";
throw new Exception();
}
?>
--EXPECTF--
1
finally
Fatal error: Uncaught exception 'Exception' in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
-10
View File
@@ -1,10 +0,0 @@
--TEST--
Bug #69892: Different arrays compare indentical due to integer key truncation
--SKIPIF--
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); ?>
--FILE--
<?php
var_dump([0 => 0] === [0x100000000 => 0]);
?>
--EXPECT--
bool(false)
-22
View File
@@ -1,22 +0,0 @@
--TEST--
Bug #69419: Returning compatible sub generator produces a warning
--FILE--
<?php
function & genRefInner() {
$var = 1;
yield $var;
}
function & genRefOuter() {
return genRefInner();
}
foreach(genRefOuter() as $i) {
var_dump($i);
}
?>
--EXPECTF--
Notice: Only variable references should be returned by reference in %s on line %d
int(1)
-2
View File
@@ -3,8 +3,6 @@
--FILE--
<?php
use A;
use \B;
--EXPECTF--
Warning: The use statement with non-compound name 'A' has no effect in %sns_033.php on line 2
Warning: The use statement with non-compound name 'B' has no effect in %sns_033.php on line 3
-17
View File
@@ -1,17 +0,0 @@
--TEST--
Closure::__invoke() with variadic parameter
--FILE--
<?php
$closure = function(&...$refs) {};
$closure->__invoke(
$v1, $v2, $v3, $v4,
$v5, $v6, $v7, $v8,
$v9, $v10, $v11, $v12,
$v13
);
?>
===DONE===
--EXPECT--
===DONE===
+13 -13
View File
@@ -678,7 +678,7 @@ static inline unsigned int zend_mm_high_bit(size_t _size)
__asm {
bsr eax, _size
}
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__) || defined(__powerpc__))
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
return (8 * SIZEOF_SIZE_T - 1) - __builtin_clzl(_size);
#else
unsigned int n = 0;
@@ -706,7 +706,7 @@ static inline unsigned int zend_mm_low_bit(size_t _size)
__asm {
bsf eax, _size
}
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__) || defined(__powerpc__))
#elif defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
return __builtin_ctzl(_size);
#else
static const int offset[16] = {4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0};
@@ -984,7 +984,7 @@ static void zend_mm_random(unsigned char *buf, size_t size) /* {{{ */
int has_context = 0;
if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) {
/* Could mean that the key container does not exist, let try
/* Could mean that the key container does not exist, let try
again by asking for a new one */
if (GetLastError() == NTE_BAD_KEYSET) {
if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
@@ -1348,7 +1348,7 @@ static int zend_mm_check_ptr(zend_mm_heap *heap, void *ptr, int silent ZEND_FILE
}
if (!silent) {
TSRMLS_FETCH();
zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL TSRMLS_CC);
zend_debug_alloc_output("---------------------------------------\n");
zend_debug_alloc_output("%s(%d) : Block "PTR_FMT" status:\n" ZEND_FILE_LINE_RELAY_CC, ptr);
@@ -2175,7 +2175,7 @@ static void *_zend_mm_realloc_int(zend_mm_heap *heap, void *p, size_t size ZEND_
#if ZEND_MM_CACHE
if (ZEND_MM_SMALL_SIZE(true_size)) {
size_t index = ZEND_MM_BUCKET_INDEX(true_size);
if (heap->cache[index] != NULL) {
zend_mm_free_block *best_fit;
zend_mm_free_block **cache;
@@ -2188,7 +2188,7 @@ static void *_zend_mm_realloc_int(zend_mm_heap *heap, void *p, size_t size ZEND_
heap->cache[index] = best_fit->prev_free_block;
ZEND_MM_CHECK_MAGIC(best_fit, MEM_BLOCK_CACHED);
ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0);
ptr = ZEND_MM_DATA_OF(best_fit);
#if ZEND_DEBUG || ZEND_MM_HEAP_PROTECTION
@@ -2470,7 +2470,7 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
: "%0"(res),
"rm"(size),
"rm"(offset));
if (UNEXPECTED(overflow)) {
zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset);
return 0;
@@ -2619,7 +2619,7 @@ ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LI
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
size_t length;
int length;
char *p;
#ifdef ZEND_SIGNALS
TSRMLS_FETCH();
@@ -2627,13 +2627,13 @@ ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
HANDLE_BLOCK_INTERRUPTIONS();
length = strlen(s);
p = (char *) _emalloc(safe_address(length, 1, 1) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
length = strlen(s)+1;
p = (char *) _emalloc(length ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
if (UNEXPECTED(p == NULL)) {
HANDLE_UNBLOCK_INTERRUPTIONS();
return p;
}
memcpy(p, s, length+1);
memcpy(p, s, length);
HANDLE_UNBLOCK_INTERRUPTIONS();
return p;
}
@@ -2647,7 +2647,7 @@ ZEND_API char *_estrndup(const char *s, uint length ZEND_FILE_LINE_DC ZEND_FILE_
HANDLE_BLOCK_INTERRUPTIONS();
p = (char *) _emalloc(safe_address(length, 1, 1) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
p = (char *) _emalloc(length+1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
if (UNEXPECTED(p == NULL)) {
HANDLE_UNBLOCK_INTERRUPTIONS();
return p;
@@ -2668,7 +2668,7 @@ ZEND_API char *zend_strndup(const char *s, uint length)
HANDLE_BLOCK_INTERRUPTIONS();
p = (char *) malloc(safe_address(length, 1, 1));
p = (char *) malloc(length+1);
if (UNEXPECTED(p == NULL)) {
HANDLE_UNBLOCK_INTERRUPTIONS();
return p;
+1 -3
View File
@@ -148,12 +148,10 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC) /* {
{
zend_closure *closure = (zend_closure *)zend_object_store_get_object(obj TSRMLS_CC);
zend_function *invoke = (zend_function*)emalloc(sizeof(zend_function));
const zend_uint keep_flags = ZEND_ACC_RETURN_REFERENCE | ZEND_ACC_VARIADIC;
invoke->common = closure->func.common;
invoke->type = ZEND_INTERNAL_FUNCTION;
invoke->internal_function.fn_flags =
ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & keep_flags);
invoke->internal_function.fn_flags = ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & ZEND_ACC_RETURN_REFERENCE);
invoke->internal_function.handler = ZEND_MN(Closure___invoke);
invoke->internal_function.module = 0;
invoke->internal_function.scope = zend_ce_closure;
+10 -12
View File
@@ -4051,8 +4051,7 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, const
}
zend_hash_quick_update(*overriden, arKey, nKeyLength, h, fn, sizeof(zend_function), (void**)&fn);
return;
} else if (existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT &&
(existing_fn->common.scope->ce_flags & ZEND_ACC_INTERFACE) == 0) {
} else if (existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
/* Make sure the trait method is compatible with previosly declared abstract method */
if (!zend_traits_method_compatibility_check(fn, existing_fn TSRMLS_CC)) {
zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s",
@@ -4082,7 +4081,6 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, const
/* inherited members are overridden by members inserted by traits */
/* check whether the trait method fulfills the inheritance requirements */
do_inheritance_check_on_method(fn, existing_fn TSRMLS_CC);
fn->common.prototype = NULL;
}
}
@@ -4101,7 +4099,7 @@ static int zend_fixup_trait_method(zend_function *fn, zend_class_entry *ce TSRML
if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
}
if (fn->type == ZEND_USER_FUNCTION && fn->op_array.static_variables) {
if (fn->op_array.static_variables) {
ce->ce_flags |= ZEND_HAS_STATIC_IN_METHODS;
}
}
@@ -7143,7 +7141,7 @@ void zend_do_begin_namespace(const znode *name, zend_bool with_bracket TSRMLS_DC
}
/* }}} */
void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{{ */
{
char *lcname;
zval *name, *ns, tmp;
@@ -7170,7 +7168,7 @@ void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
ZVAL_STRING(name, p+1, 1);
} else {
ZVAL_ZVAL(name, ns, 1, 0);
warn = !CG(current_namespace);
warn = !is_global && !CG(current_namespace);
}
}
@@ -7226,7 +7224,7 @@ void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
}
/* }}} */
void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_function, zend_bool case_sensitive, HashTable *current_import_sub, HashTable *lookup_table TSRMLS_DC) /* {{{ */
void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, int is_function, zend_bool case_sensitive, HashTable *current_import_sub, HashTable *lookup_table TSRMLS_DC) /* {{{ */
{
char *lookup_name;
zval *name, *ns, tmp;
@@ -7247,7 +7245,7 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_function, zen
ZVAL_STRING(name, p+1, 1);
} else {
ZVAL_ZVAL(name, ns, 1, 0);
warn = !CG(current_namespace);
warn = !is_global && !CG(current_namespace);
}
}
@@ -7311,25 +7309,25 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_function, zen
}
/* }}} */
void zend_do_use_function(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
void zend_do_use_function(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{{ */
{
if (!CG(current_import_function)) {
CG(current_import_function) = emalloc(sizeof(HashTable));
zend_hash_init(CG(current_import_function), 0, NULL, ZVAL_PTR_DTOR, 0);
}
zend_do_use_non_class(ns_name, new_name, 1, 0, CG(current_import_function), CG(function_table) TSRMLS_CC);
zend_do_use_non_class(ns_name, new_name, is_global, 1, 0, CG(current_import_function), CG(function_table) TSRMLS_CC);
}
/* }}} */
void zend_do_use_const(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
void zend_do_use_const(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{{ */
{
if (!CG(current_import_const)) {
CG(current_import_const) = emalloc(sizeof(HashTable));
zend_hash_init(CG(current_import_const), 0, NULL, ZVAL_PTR_DTOR, 0);
}
zend_do_use_non_class(ns_name, new_name, 0, 1, CG(current_import_const), &CG(const_filenames) TSRMLS_CC);
zend_do_use_non_class(ns_name, new_name, is_global, 0, 1, CG(current_import_const), &CG(const_filenames) TSRMLS_CC);
}
/* }}} */
+4 -4
View File
@@ -651,10 +651,10 @@ void zend_do_build_namespace_name(znode *result, znode *prefix, znode *name TSRM
void zend_do_begin_namespace(const znode *name, zend_bool with_brackets TSRMLS_DC);
void zend_do_end_namespace(TSRMLS_D);
void zend_verify_namespace(TSRMLS_D);
void zend_do_use(znode *name, znode *new_name TSRMLS_DC);
void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_function, zend_bool case_sensitive, HashTable *current_import_sub, HashTable *lookup_table TSRMLS_DC);
void zend_do_use_function(znode *name, znode *new_name TSRMLS_DC);
void zend_do_use_const(znode *name, znode *new_name TSRMLS_DC);
void zend_do_use(znode *name, znode *new_name, int is_global TSRMLS_DC);
void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, int is_function, zend_bool case_sensitive, HashTable *current_import_sub, HashTable *lookup_table TSRMLS_DC);
void zend_do_use_function(znode *name, znode *new_name, int is_global TSRMLS_DC);
void zend_do_use_const(znode *name, znode *new_name, int is_global TSRMLS_DC);
void zend_do_end_compilation(TSRMLS_D);
void zend_do_constant_expression(znode *result, zend_ast *ast TSRMLS_DC);
+1 -1
View File
@@ -588,7 +588,7 @@ ZEND_METHOD(exception, getTraceAsString)
DEFAULT_0_PARAMS;
trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
if (Z_TYPE_P(trace) != IS_ARRAY) {
if(Z_TYPE_P(trace) != IS_ARRAY) {
RETURN_FALSE;
}
-4
View File
@@ -1585,10 +1585,6 @@ ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */
ex->symbol_table = EG(active_symbol_table);
for (i = 0; i < ex->op_array->last_var; i++) {
if (*EX_CV_NUM(ex, i)) {
if (UNEXPECTED(**EX_CV_NUM(ex, i) == &EG(uninitialized_zval))) {
Z_DELREF(EG(uninitialized_zval));
ALLOC_INIT_ZVAL(**EX_CV_NUM(ex, i));
}
zend_hash_quick_update(EG(active_symbol_table),
ex->op_array->vars[i].name,
ex->op_array->vars[i].name_len + 1,
+7 -2
View File
@@ -147,6 +147,8 @@ ZEND_API void gc_zval_possible_root(zval *zv TSRMLS_DC)
GC_BENCH_INC(zval_possible_root);
if (GC_ZVAL_GET_COLOR(zv) != GC_PURPLE) {
GC_ZVAL_SET_PURPLE(zv);
if (!GC_ZVAL_ADDRESS(zv)) {
gc_root_buffer *newRoot = GC_G(unused);
@@ -157,6 +159,7 @@ ZEND_API void gc_zval_possible_root(zval *zv TSRMLS_DC)
GC_G(first_unused)++;
} else {
if (!GC_G(gc_enabled)) {
GC_ZVAL_SET_BLACK(zv);
return;
}
zv->refcount__gc++;
@@ -166,10 +169,10 @@ ZEND_API void gc_zval_possible_root(zval *zv TSRMLS_DC)
if (!newRoot) {
return;
}
GC_ZVAL_SET_PURPLE(zv);
GC_G(unused) = newRoot->prev;
}
GC_ZVAL_SET_PURPLE(zv);
newRoot->next = GC_G(roots).next;
newRoot->prev = &GC_G(roots);
GC_G(roots).next->prev = newRoot;
@@ -200,6 +203,7 @@ ZEND_API void gc_zobj_possible_root(zval *zv TSRMLS_DC)
obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zv)].bucket.obj;
if (GC_GET_COLOR(obj->buffered) != GC_PURPLE) {
GC_SET_PURPLE(obj->buffered);
if (!GC_ADDRESS(obj->buffered)) {
gc_root_buffer *newRoot = GC_G(unused);
@@ -210,6 +214,7 @@ ZEND_API void gc_zobj_possible_root(zval *zv TSRMLS_DC)
GC_G(first_unused)++;
} else {
if (!GC_G(gc_enabled)) {
GC_ZVAL_SET_BLACK(zv);
return;
}
zv->refcount__gc++;
@@ -220,10 +225,10 @@ ZEND_API void gc_zobj_possible_root(zval *zv TSRMLS_DC)
return;
}
obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zv)].bucket.obj;
GC_SET_PURPLE(obj->buffered);
GC_G(unused) = newRoot->prev;
}
GC_SET_PURPLE(obj->buffered);
newRoot->next = GC_G(roots).next;
newRoot->prev = &GC_G(roots);
GC_G(roots).next->prev = newRoot;
-3
View File
@@ -198,9 +198,6 @@ static void zend_generator_dtor_storage(zend_generator *generator, zend_object_h
if (finally_op_num) {
ex->opline = &ex->op_array->opcodes[finally_op_num];
ex->fast_ret = NULL;
ex->delayed_exception = EG(exception);
EG(exception) = NULL;
generator->flags |= ZEND_GENERATOR_FORCED_CLOSE;
zend_generator_resume(generator TSRMLS_CC);
}
+3 -2
View File
@@ -1446,10 +1446,11 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
}
if (ordered) {
if (p1->nKeyLength==0 && p2->nKeyLength==0) { /* numeric indices */
if (p1->h != p2->h) {
result = p1->h - p2->h;
if (result!=0) {
HASH_UNPROTECT_RECURSION(ht1);
HASH_UNPROTECT_RECURSION(ht2);
return p1->h > p2->h ? 1 : -1;
return result;
}
} else { /* string indices */
result = p1->nKeyLength - p2->nKeyLength;
+1 -1
View File
@@ -2029,7 +2029,7 @@ end_raw_value_chars:
}
/* Eat leading and trailing double quotes */
if (yyleng > 1 && yytext[0] == '"' && yytext[yyleng - 1] == '"') {
if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
SCNG(yy_text)++;
yyleng = yyleng - 2;
} else if (sc) {
+1 -1
View File
@@ -523,7 +523,7 @@ end_raw_value_chars:
}
/* Eat leading and trailing double quotes */
if (yyleng > 1 && yytext[0] == '"' && yytext[yyleng - 1] == '"') {
if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
SCNG(yy_text)++;
yyleng = yyleng - 2;
} else if (sc) {
+12 -12
View File
@@ -255,10 +255,10 @@ use_declarations:
;
use_declaration:
namespace_name { zend_do_use(&$1, NULL TSRMLS_CC); }
| namespace_name T_AS T_STRING { zend_do_use(&$1, &$3 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name { zend_do_use(&$2, NULL TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name T_AS T_STRING { zend_do_use(&$2, &$4 TSRMLS_CC); }
namespace_name { zend_do_use(&$1, NULL, 0 TSRMLS_CC); }
| namespace_name T_AS T_STRING { zend_do_use(&$1, &$3, 0 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name { zend_do_use(&$2, NULL, 1 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name T_AS T_STRING { zend_do_use(&$2, &$4, 1 TSRMLS_CC); }
;
use_function_declarations:
@@ -267,10 +267,10 @@ use_function_declarations:
;
use_function_declaration:
namespace_name { zend_do_use_function(&$1, NULL TSRMLS_CC); }
| namespace_name T_AS T_STRING { zend_do_use_function(&$1, &$3 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name { zend_do_use_function(&$2, NULL TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name T_AS T_STRING { zend_do_use_function(&$2, &$4 TSRMLS_CC); }
namespace_name { zend_do_use_function(&$1, NULL, 0 TSRMLS_CC); }
| namespace_name T_AS T_STRING { zend_do_use_function(&$1, &$3, 0 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name { zend_do_use_function(&$2, NULL, 1 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name T_AS T_STRING { zend_do_use_function(&$2, &$4, 1 TSRMLS_CC); }
;
use_const_declarations:
@@ -279,10 +279,10 @@ use_const_declarations:
;
use_const_declaration:
namespace_name { zend_do_use_const(&$1, NULL TSRMLS_CC); }
| namespace_name T_AS T_STRING { zend_do_use_const(&$1, &$3 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name { zend_do_use_const(&$2, NULL TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name T_AS T_STRING { zend_do_use_const(&$2, &$4 TSRMLS_CC); }
namespace_name { zend_do_use_const(&$1, NULL, 0 TSRMLS_CC); }
| namespace_name T_AS T_STRING { zend_do_use_const(&$1, &$3, 0 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name { zend_do_use_const(&$2, NULL, 1 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name T_AS T_STRING { zend_do_use_const(&$2, &$4, 1 TSRMLS_CC); }
;
constant_declaration:
+7 -7
View File
@@ -162,16 +162,16 @@ static inline void cleanup_user_class_data(zend_class_entry *ce TSRMLS_DC)
zend_hash_apply(&ce->function_table, (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC);
}
if (ce->static_members_table) {
zval **static_members = ce->static_members_table;
int count = ce->default_static_members_count;
int i;
ce->default_static_members_count = 0;
ce->default_static_members_table = ce->static_members_table = NULL;
for (i = 0; i < count; i++) {
zval_ptr_dtor(&static_members[i]);
for (i = 0; i < ce->default_static_members_count; i++) {
if (ce->static_members_table[i]) {
zval *p = ce->static_members_table[i];
ce->static_members_table[i] = NULL;
zval_ptr_dtor(&p);
}
}
efree(static_members);
ce->static_members_table = NULL;
}
}
+2 -7
View File
@@ -1456,19 +1456,14 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
zend_error(E_ERROR, "String size overflow");
}
Z_STRVAL_P(result) = safe_erealloc(Z_STRVAL_P(result), res_len, 1, 1);
Z_STRVAL_P(result) = erealloc(Z_STRVAL_P(result), res_len+1);
memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(result), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
Z_STRVAL_P(result)[res_len]=0;
Z_STRLEN_P(result) = res_len;
} else {
int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
char *buf;
if (Z_STRLEN_P(op1) < 0 || Z_STRLEN_P(op2) < 0 || (int) (Z_STRLEN_P(op1) + Z_STRLEN_P(op2)) < 0) {
zend_error(E_ERROR, "String size overflow");
}
buf = (char *) safe_emalloc(length, 1, 1);
char *buf = (char *) emalloc(length + 1);
memcpy(buf, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
memcpy(buf + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
+1 -1
View File
@@ -261,7 +261,7 @@ CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){
}
dwRet = pGetFinalPathNameByHandle(hFile, target, MAXPATHLEN, VOLUME_NAME_DOS);
if(dwRet >= MAXPATHLEN || dwRet == 0) {
if(dwRet >= MAXPATHLEN) {
return -1;
}
+10 -11
View File
@@ -1753,9 +1753,7 @@ ZEND_VM_HANDLER(38, ZEND_ASSIGN, VAR|CV, CONST|TMP|VAR|CV)
}
}
if (OP1_TYPE == IS_VAR && OP1_FREE) {
zval_ptr_dtor_nogc(&value);
}
FREE_OP1_VAR_PTR();
/* zend_assign_to_variable() always takes care of op2, never free it! */
FREE_OP2_IF_VAR();
@@ -1889,7 +1887,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
EX(call)--;
zend_vm_stack_clear_multiple(0 TSRMLS_CC);
zend_vm_stack_clear_multiple(1 TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
zend_throw_exception_internal(NULL TSRMLS_CC);
@@ -1997,12 +1995,13 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
EX_T(opline->result.var).var.ptr = NULL;
}
} else if (fbc->type == ZEND_USER_FUNCTION) {
temp_variable *ret = &EX_T(opline->result.var);
EX(original_return_value) = EG(return_value_ptr_ptr);
EG(active_symbol_table) = NULL;
EG(active_op_array) = &fbc->op_array;
EG(return_value_ptr_ptr) = NULL;
if (RETURN_VALUE_USED(opline)) {
temp_variable *ret = &EX_T(opline->result.var);
ret->var.ptr = NULL;
EG(return_value_ptr_ptr) = &ret->var.ptr;
ret->var.ptr_ptr = &ret->var.ptr;
@@ -2011,8 +2010,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
if (UNEXPECTED((EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) {
if (RETURN_VALUE_USED(opline)) {
ret->var.ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC);
ret->var.fcall_returned_reference = 0;
EX_T(opline->result.var).var.ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC);
}
} else if (EXPECTED(zend_execute_ex == execute_ex)) {
if (EXPECTED(EG(exception) == NULL)) {
@@ -2077,7 +2075,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
EX(call)--;
zend_vm_stack_clear_multiple(0 TSRMLS_CC);
zend_vm_stack_clear_multiple(1 TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
zend_throw_exception_internal(NULL TSRMLS_CC);
@@ -5427,6 +5425,7 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED)
{
USE_OPLINE
zend_function *op_array;
int closure_is_static, closure_is_being_defined_inside_static_context;
SAVE_OPLINE();
@@ -5435,9 +5434,9 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED)
zend_error_noreturn(E_ERROR, "Base lambda function for closure not found");
}
if (UNEXPECTED((op_array->common.fn_flags & ZEND_ACC_STATIC) ||
(EX(prev_execute_data) &&
EX(prev_execute_data)->function_state.function->common.fn_flags & ZEND_ACC_STATIC))) {
closure_is_static = op_array->common.fn_flags & ZEND_ACC_STATIC;
closure_is_being_defined_inside_static_context = EX(prev_execute_data) && EX(prev_execute_data)->function_state.function->common.fn_flags & ZEND_ACC_STATIC;
if (closure_is_static || closure_is_being_defined_inside_static_context) {
zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(called_scope), NULL TSRMLS_CC);
} else {
zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(scope), EG(This) TSRMLS_CC);
+13 -36
View File
@@ -459,7 +459,7 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
EX(call)--;
zend_vm_stack_clear_multiple(0 TSRMLS_CC);
zend_vm_stack_clear_multiple(1 TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
zend_throw_exception_internal(NULL TSRMLS_CC);
@@ -567,12 +567,13 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
EX_T(opline->result.var).var.ptr = NULL;
}
} else if (fbc->type == ZEND_USER_FUNCTION) {
temp_variable *ret = &EX_T(opline->result.var);
EX(original_return_value) = EG(return_value_ptr_ptr);
EG(active_symbol_table) = NULL;
EG(active_op_array) = &fbc->op_array;
EG(return_value_ptr_ptr) = NULL;
if (RETURN_VALUE_USED(opline)) {
temp_variable *ret = &EX_T(opline->result.var);
ret->var.ptr = NULL;
EG(return_value_ptr_ptr) = &ret->var.ptr;
ret->var.ptr_ptr = &ret->var.ptr;
@@ -581,8 +582,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
if (UNEXPECTED((EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) {
if (RETURN_VALUE_USED(opline)) {
ret->var.ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC);
ret->var.fcall_returned_reference = 0;
EX_T(opline->result.var).var.ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC);
}
} else if (EXPECTED(zend_execute_ex == execute_ex)) {
if (EXPECTED(EG(exception) == NULL)) {
@@ -647,7 +647,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
EX(call)--;
zend_vm_stack_clear_multiple(0 TSRMLS_CC);
zend_vm_stack_clear_multiple(1 TSRMLS_CC);
if (UNEXPECTED(EG(exception) != NULL)) {
zend_throw_exception_internal(NULL TSRMLS_CC);
@@ -6801,6 +6801,7 @@ static int ZEND_FASTCALL ZEND_DECLARE_LAMBDA_FUNCTION_SPEC_CONST_UNUSED_HANDLER
{
USE_OPLINE
zend_function *op_array;
int closure_is_static, closure_is_being_defined_inside_static_context;
SAVE_OPLINE();
@@ -6809,9 +6810,9 @@ static int ZEND_FASTCALL ZEND_DECLARE_LAMBDA_FUNCTION_SPEC_CONST_UNUSED_HANDLER
zend_error_noreturn(E_ERROR, "Base lambda function for closure not found");
}
if (UNEXPECTED((op_array->common.fn_flags & ZEND_ACC_STATIC) ||
(EX(prev_execute_data) &&
EX(prev_execute_data)->function_state.function->common.fn_flags & ZEND_ACC_STATIC))) {
closure_is_static = op_array->common.fn_flags & ZEND_ACC_STATIC;
closure_is_being_defined_inside_static_context = EX(prev_execute_data) && EX(prev_execute_data)->function_state.function->common.fn_flags & ZEND_ACC_STATIC;
if (closure_is_static || closure_is_being_defined_inside_static_context) {
zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(called_scope), NULL TSRMLS_CC);
} else {
zend_create_closure(&EX_T(opline->result.var).tmp_var, (zend_function *) op_array, EG(scope), EG(This) TSRMLS_CC);
@@ -15692,9 +15693,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER
}
}
if (IS_VAR == IS_VAR && (free_op1.var != NULL)) {
zval_ptr_dtor_nogc(&value);
}
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
/* zend_assign_to_variable() always takes care of op2, never free it! */
@@ -18045,9 +18044,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_A
}
}
if (IS_VAR == IS_VAR && (free_op1.var != NULL)) {
zval_ptr_dtor_nogc(&value);
}
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
/* zend_assign_to_variable() always takes care of op2, never free it! */
@@ -20307,9 +20304,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_A
}
}
if (IS_VAR == IS_VAR && (free_op1.var != NULL)) {
zval_ptr_dtor_nogc(&value);
}
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
/* zend_assign_to_variable() always takes care of op2, never free it! */
zval_ptr_dtor_nogc(&free_op2.var);
@@ -23778,9 +23773,7 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_AR
}
}
if (IS_VAR == IS_VAR && (free_op1.var != NULL)) {
zval_ptr_dtor_nogc(&value);
}
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
/* zend_assign_to_variable() always takes care of op2, never free it! */
@@ -33219,10 +33212,6 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_
}
}
if (IS_CV == IS_VAR && 0) {
zval_ptr_dtor_nogc(&value);
}
/* zend_assign_to_variable() always takes care of op2, never free it! */
CHECK_EXCEPTION();
@@ -35343,10 +35332,6 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_AR
}
}
if (IS_CV == IS_VAR && 0) {
zval_ptr_dtor_nogc(&value);
}
/* zend_assign_to_variable() always takes care of op2, never free it! */
CHECK_EXCEPTION();
@@ -37468,10 +37453,6 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_AR
}
}
if (IS_CV == IS_VAR && 0) {
zval_ptr_dtor_nogc(&value);
}
/* zend_assign_to_variable() always takes care of op2, never free it! */
zval_ptr_dtor_nogc(&free_op2.var);
@@ -40652,10 +40633,6 @@ static int ZEND_FASTCALL ZEND_ASSIGN_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARG
}
}
if (IS_CV == IS_VAR && 0) {
zval_ptr_dtor_nogc(&value);
}
/* zend_assign_to_variable() always takes care of op2, never free it! */
CHECK_EXCEPTION();
+1 -1
View File
@@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=5
PHP_MINOR_VERSION=6
PHP_RELEASE_VERSION=11
PHP_RELEASE_VERSION=8
PHP_EXTRA_VERSION=""
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
+27 -27
View File
@@ -115,7 +115,7 @@ static double astro_GMST0(double d)
/* time, imposing no runtime or code overhead. */
sidtim0 = astro_revolution((180.0 + 356.0470 + 282.9404) + (0.9856002585 + 4.70935E-5) * d);
return sidtim0;
}
}
/* This function computes the Sun's position at any instant */
@@ -177,32 +177,32 @@ static void astro_sun_RA_dec(double d, double *RA, double *dec, double *r)
/**
* Note: timestamp = unixtimestamp (NEEDS to be 00:00:00 UT)
* Eastern longitude positive, Western longitude negative
* Northern latitude positive, Southern latitude negative
* The longitude value IS critical in this function!
* altit = the altitude which the Sun should cross
* Set to -35/60 degrees for rise/set, -6 degrees
* for civil, -12 degrees for nautical and -18
* degrees for astronomical twilight.
* upper_limb: non-zero -> upper limb, zero -> center
* Set to non-zero (e.g. 1) when computing rise/set
* times, and to zero when computing start/end of
* twilight.
* *rise = where to store the rise time
* *set = where to store the set time
* Both times are relative to the specified altitude,
* and thus this function can be used to compute
* various twilight times, as well as rise/set times
* Return value: 0 = sun rises/sets this day, times stored at
* *trise and *tset.
* +1 = sun above the specified "horizon" 24 hours.
* *trise set to time when the sun is at south,
* minus 12 hours while *tset is set to the south
* time plus 12 hours. "Day" length = 24 hours
* -1 = sun is below the specified "horizon" 24 hours
* "Day" length = 0 hours, *trise and *tset are
* both set to the time when the sun is at south.
*
* Eastern longitude positive, Western longitude negative
* Northern latitude positive, Southern latitude negative
* The longitude value IS critical in this function!
* altit = the altitude which the Sun should cross
* Set to -35/60 degrees for rise/set, -6 degrees
* for civil, -12 degrees for nautical and -18
* degrees for astronomical twilight.
* upper_limb: non-zero -> upper limb, zero -> center
* Set to non-zero (e.g. 1) when computing rise/set
* times, and to zero when computing start/end of
* twilight.
* *rise = where to store the rise time
* *set = where to store the set time
* Both times are relative to the specified altitude,
* and thus this function can be used to compute
* various twilight times, as well as rise/set times
* Return value: 0 = sun rises/sets this day, times stored at
* *trise and *tset.
* +1 = sun above the specified "horizon" 24 hours.
* *trise set to time when the sun is at south,
* minus 12 hours while *tset is set to the south
* time plus 12 hours. "Day" length = 24 hours
* -1 = sun is below the specified "horizon" 24 hours
* "Day" length = 0 hours, *trise and *tset are
* both set to the time when the sun is at south.
*
*/
int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat, double altit, int upper_limb, double *h_rise, double *h_set, timelib_sll *ts_rise, timelib_sll *ts_set, timelib_sll *ts_transit)
{
+1 -1
View File
@@ -136,7 +136,7 @@ void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, time
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d)
{
timelib_sll dow, day;
/* Figure out the dayofweek for y-1-1 */
dow = timelib_day_of_week(y, 1, 1);
/* then use that to figure out the offset for day 1 of week 1 */
+10 -10
View File
@@ -677,7 +677,7 @@ const static timelib_tz_lookup_table* abbr_search(const char *word, long gmtoffs
if (strcasecmp("utc", word) == 0 || strcasecmp("gmt", word) == 0) {
return timelib_timezone_utc;
}
for (tp = timelib_timezone_lookup; tp->name; tp++) {
if (strcasecmp(word, tp->name) == 0) {
if (!first_found) {
@@ -808,7 +808,7 @@ static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper)
{
uchar *cursor = s->cur;
char *str, *ptr = NULL;
std:
s->tok = cursor;
s->len = 0;
@@ -1437,7 +1437,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
TIMELIB_HAVE_RELATIVE();
s->time->y = timelib_get_nr((char **) &ptr, 4);
w = timelib_get_nr((char **) &ptr, 2);
d = timelib_get_nr((char **) &ptr, 1);
@@ -1456,7 +1456,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
TIMELIB_INIT;
TIMELIB_HAVE_DATE();
TIMELIB_HAVE_RELATIVE();
s->time->y = timelib_get_nr((char **) &ptr, 4);
w = timelib_get_nr((char **) &ptr, 2);
d = 1;
@@ -1560,7 +1560,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
if (s->time->relative.weekday_behavior != 2) {
s->time->relative.weekday_behavior = 1;
}
TIMELIB_DEINIT;
return TIMELIB_WEEKDAY;
}
@@ -1877,7 +1877,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
add_pbf_error(s, "A textual day could not be found", string, begin);
break;
} else {
in.time->have_relative = 1;
in.time->have_relative = 1;
in.time->relative.have_weekday_relative = 1;
in.time->relative.weekday = tmprel->multiplier;
in.time->relative.weekday_behavior = 1;
@@ -2148,13 +2148,13 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
/* do funky checking whether the parsed time was valid time */
if (s->time->h != TIMELIB_UNSET && s->time->i != TIMELIB_UNSET &&
s->time->s != TIMELIB_UNSET &&
s->time->s != TIMELIB_UNSET &&
!timelib_valid_time( s->time->h, s->time->i, s->time->s)) {
add_pbf_warning(s, "The parsed time was invalid", string, ptr);
}
/* do funky checking whether the parsed date was valid date */
if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET &&
s->time->d != TIMELIB_UNSET &&
s->time->d != TIMELIB_UNSET &&
!timelib_valid_date( s->time->y, s->time->m, s->time->d)) {
add_pbf_warning(s, "The parsed date was invalid", string, ptr);
}
@@ -2227,7 +2227,7 @@ int main(void)
printf ("%04d-%02d-%02d %02d:%02d:%02d.%-5d %+04d %1d",
time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
if (time.have_relative) {
printf ("%3dY %3dM %3dD / %3dH %3dM %3dS",
printf ("%3dY %3dM %3dD / %3dH %3dM %3dS",
time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative.s);
}
if (time.have_weekday_relative) {
@@ -2236,7 +2236,7 @@ int main(void)
if (time.have_weeknr_day) {
printf(" / %dW%d", time.relative.weeknr_day.weeknr, time.relative.weeknr_day.dayofweek);
}
return 0;
return 0;
}
#endif
+6 -6
View File
@@ -242,7 +242,7 @@ static int scan(Scanner *s)
{
uchar *cursor = s->cur;
char *str, *ptr = NULL;
std:
s->tok = cursor;
s->len = 0;
@@ -336,11 +336,11 @@ isoweek = year4 "-"? "W" weekofyear;
case 'D': s->period->d = nr; break;
case 'H': s->period->h = nr; break;
case 'S': s->period->s = nr; break;
case 'M':
case 'M':
if (in_time) {
s->period->i = nr;
} else {
s->period->m = nr;
s->period->m = nr;
}
break;
default:
@@ -398,9 +398,9 @@ isoweek = year4 "-"? "W" weekofyear;
/*!max:re2c */
void timelib_strtointerval(char *s, int len,
timelib_time **begin, timelib_time **end,
timelib_rel_time **period, int *recurrences,
void timelib_strtointerval(char *s, int len,
timelib_time **begin, timelib_time **end,
timelib_rel_time **period, int *recurrences,
struct timelib_error_container **errors)
{
Scanner in;
+68 -135
View File
@@ -36,7 +36,7 @@
#if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
# if defined(__LITTLE_ENDIAN__)
# undef WORDS_BIGENDIAN
# else
# else
# if defined(__BIG_ENDIAN__)
# define WORDS_BIGENDIAN
# endif
@@ -49,14 +49,11 @@
#define timelib_conv_int(l) ((l & 0x000000ff) << 24) + ((l & 0x0000ff00) << 8) + ((l & 0x00ff0000) >> 8) + ((l & 0xff000000) >> 24)
#endif
static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
static void read_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
{
uint32_t version;
/* read ID */
version = (*tzf)[3] - '0';
/* skip ID */
*tzf += 4;
/* read BC flag */
tz->bc = (**tzf == '\1');
*tzf += 1;
@@ -66,10 +63,8 @@ static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
tz->location.country_code[2] = '\0';
*tzf += 2;
/* skip rest of preamble */
/* skip read of preamble */
*tzf += 13;
return version;
}
static void read_header(const unsigned char **tzf, timelib_tzinfo *tz)
@@ -77,88 +72,65 @@ static void read_header(const unsigned char **tzf, timelib_tzinfo *tz)
uint32_t buffer[6];
memcpy(&buffer, *tzf, sizeof(buffer));
tz->bit32.ttisgmtcnt = timelib_conv_int(buffer[0]);
tz->bit32.ttisstdcnt = timelib_conv_int(buffer[1]);
tz->bit32.leapcnt = timelib_conv_int(buffer[2]);
tz->bit32.timecnt = timelib_conv_int(buffer[3]);
tz->bit32.typecnt = timelib_conv_int(buffer[4]);
tz->bit32.charcnt = timelib_conv_int(buffer[5]);
tz->ttisgmtcnt = timelib_conv_int(buffer[0]);
tz->ttisstdcnt = timelib_conv_int(buffer[1]);
tz->leapcnt = timelib_conv_int(buffer[2]);
tz->timecnt = timelib_conv_int(buffer[3]);
tz->typecnt = timelib_conv_int(buffer[4]);
tz->charcnt = timelib_conv_int(buffer[5]);
*tzf += sizeof(buffer);
}
static void skip_64bit_transistions(const unsigned char **tzf, timelib_tzinfo *tz)
{
if (tz->bit64.timecnt) {
*tzf += (sizeof(int64_t) * tz->bit64.timecnt);
*tzf += (sizeof(unsigned char) * tz->bit64.timecnt);
}
}
static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz)
{
int32_t *buffer = NULL;
uint32_t i;
unsigned char *cbuffer = NULL;
if (tz->bit32.timecnt) {
buffer = (int32_t*) malloc(tz->bit32.timecnt * sizeof(int32_t));
if (tz->timecnt) {
buffer = (int32_t*) malloc(tz->timecnt * sizeof(int32_t));
if (!buffer) {
return;
}
memcpy(buffer, *tzf, sizeof(int32_t) * tz->bit32.timecnt);
*tzf += (sizeof(int32_t) * tz->bit32.timecnt);
for (i = 0; i < tz->bit32.timecnt; i++) {
memcpy(buffer, *tzf, sizeof(int32_t) * tz->timecnt);
*tzf += (sizeof(int32_t) * tz->timecnt);
for (i = 0; i < tz->timecnt; i++) {
buffer[i] = timelib_conv_int(buffer[i]);
}
cbuffer = (unsigned char*) malloc(tz->bit32.timecnt * sizeof(unsigned char));
cbuffer = (unsigned char*) malloc(tz->timecnt * sizeof(unsigned char));
if (!cbuffer) {
free(buffer);
return;
}
memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->bit32.timecnt);
*tzf += sizeof(unsigned char) * tz->bit32.timecnt;
memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->timecnt);
*tzf += sizeof(unsigned char) * tz->timecnt;
}
tz->trans = buffer;
tz->trans_idx = cbuffer;
}
static void skip_64bit_types(const unsigned char **tzf, timelib_tzinfo *tz)
{
*tzf += sizeof(unsigned char) * 6 * tz->bit64.typecnt;
*tzf += sizeof(char) * tz->bit64.charcnt;
if (tz->bit64.leapcnt) {
*tzf += sizeof(int64_t) * tz->bit64.leapcnt * 2;
}
if (tz->bit64.ttisstdcnt) {
*tzf += sizeof(unsigned char) * tz->bit64.ttisstdcnt;
}
if (tz->bit64.ttisgmtcnt) {
*tzf += sizeof(unsigned char) * tz->bit64.ttisgmtcnt;
}
}
static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
{
unsigned char *buffer;
int32_t *leap_buffer;
unsigned int i, j;
buffer = (unsigned char*) malloc(tz->bit32.typecnt * sizeof(unsigned char) * 6);
buffer = (unsigned char*) malloc(tz->typecnt * sizeof(unsigned char) * 6);
if (!buffer) {
return;
}
memcpy(buffer, *tzf, sizeof(unsigned char) * 6 * tz->bit32.typecnt);
*tzf += sizeof(unsigned char) * 6 * tz->bit32.typecnt;
memcpy(buffer, *tzf, sizeof(unsigned char) * 6 * tz->typecnt);
*tzf += sizeof(unsigned char) * 6 * tz->typecnt;
tz->type = (ttinfo*) malloc(tz->bit32.typecnt * sizeof(struct ttinfo));
tz->type = (ttinfo*) malloc(tz->typecnt * sizeof(struct ttinfo));
if (!tz->type) {
free(buffer);
return;
}
for (i = 0; i < tz->bit32.typecnt; i++) {
for (i = 0; i < tz->typecnt; i++) {
j = i * 6;
tz->type[i].offset = (buffer[j] * 16777216) + (buffer[j + 1] * 65536) + (buffer[j + 2] * 256) + buffer[j + 3];
tz->type[i].isdst = buffer[j + 4];
@@ -166,74 +138,62 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz)
}
free(buffer);
tz->timezone_abbr = (char*) malloc(tz->bit32.charcnt);
tz->timezone_abbr = (char*) malloc(tz->charcnt);
if (!tz->timezone_abbr) {
return;
}
memcpy(tz->timezone_abbr, *tzf, sizeof(char) * tz->bit32.charcnt);
*tzf += sizeof(char) * tz->bit32.charcnt;
memcpy(tz->timezone_abbr, *tzf, sizeof(char) * tz->charcnt);
*tzf += sizeof(char) * tz->charcnt;
if (tz->bit32.leapcnt) {
leap_buffer = (int32_t *) malloc(tz->bit32.leapcnt * 2 * sizeof(int32_t));
if (tz->leapcnt) {
leap_buffer = (int32_t *) malloc(tz->leapcnt * 2 * sizeof(int32_t));
if (!leap_buffer) {
return;
}
memcpy(leap_buffer, *tzf, sizeof(int32_t) * tz->bit32.leapcnt * 2);
*tzf += sizeof(int32_t) * tz->bit32.leapcnt * 2;
memcpy(leap_buffer, *tzf, sizeof(int32_t) * tz->leapcnt * 2);
*tzf += sizeof(int32_t) * tz->leapcnt * 2;
tz->leap_times = (tlinfo*) malloc(tz->bit32.leapcnt * sizeof(tlinfo));
tz->leap_times = (tlinfo*) malloc(tz->leapcnt * sizeof(tlinfo));
if (!tz->leap_times) {
free(leap_buffer);
return;
}
for (i = 0; i < tz->bit32.leapcnt; i++) {
for (i = 0; i < tz->leapcnt; i++) {
tz->leap_times[i].trans = timelib_conv_int(leap_buffer[i * 2]);
tz->leap_times[i].offset = timelib_conv_int(leap_buffer[i * 2 + 1]);
}
free(leap_buffer);
}
if (tz->bit32.ttisstdcnt) {
buffer = (unsigned char*) malloc(tz->bit32.ttisstdcnt * sizeof(unsigned char));
if (tz->ttisstdcnt) {
buffer = (unsigned char*) malloc(tz->ttisstdcnt * sizeof(unsigned char));
if (!buffer) {
return;
}
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit32.ttisstdcnt);
*tzf += sizeof(unsigned char) * tz->bit32.ttisstdcnt;
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->ttisstdcnt);
*tzf += sizeof(unsigned char) * tz->ttisstdcnt;
for (i = 0; i < tz->bit32.ttisstdcnt; i++) {
for (i = 0; i < tz->ttisstdcnt; i++) {
tz->type[i].isstdcnt = buffer[i];
}
free(buffer);
}
if (tz->bit32.ttisgmtcnt) {
buffer = (unsigned char*) malloc(tz->bit32.ttisgmtcnt * sizeof(unsigned char));
if (tz->ttisgmtcnt) {
buffer = (unsigned char*) malloc(tz->ttisgmtcnt * sizeof(unsigned char));
if (!buffer) {
return;
}
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit32.ttisgmtcnt);
*tzf += sizeof(unsigned char) * tz->bit32.ttisgmtcnt;
memcpy(buffer, *tzf, sizeof(unsigned char) * tz->ttisgmtcnt);
*tzf += sizeof(unsigned char) * tz->ttisgmtcnt;
for (i = 0; i < tz->bit32.ttisgmtcnt; i++) {
for (i = 0; i < tz->ttisgmtcnt; i++) {
tz->type[i].isgmtcnt = buffer[i];
}
free(buffer);
}
}
static void skip_posix_string(const unsigned char **tzf, timelib_tzinfo *tz)
{
int n_count = 0;
do {
if (*tzf[0] == '\n') {
n_count++;
}
(*tzf)++;
} while (n_count < 2);
}
static void read_location(const unsigned char **tzf, timelib_tzinfo *tz)
{
uint32_t buffer[3];
@@ -261,12 +221,12 @@ void timelib_dump_tzinfo(timelib_tzinfo *tz)
printf("Geo Location: %f,%f\n", tz->location.latitude, tz->location.longitude);
printf("Comments:\n%s\n", tz->location.comments);
printf("BC: %s\n", tz->bc ? "" : "yes");
printf("UTC/Local count: %lu\n", (unsigned long) tz->bit32.ttisgmtcnt);
printf("Std/Wall count: %lu\n", (unsigned long) tz->bit32.ttisstdcnt);
printf("Leap.sec. count: %lu\n", (unsigned long) tz->bit32.leapcnt);
printf("Trans. count: %lu\n", (unsigned long) tz->bit32.timecnt);
printf("Local types count: %lu\n", (unsigned long) tz->bit32.typecnt);
printf("Zone Abbr. count: %lu\n", (unsigned long) tz->bit32.charcnt);
printf("UTC/Local count: %lu\n", (unsigned long) tz->ttisgmtcnt);
printf("Std/Wall count: %lu\n", (unsigned long) tz->ttisstdcnt);
printf("Leap.sec. count: %lu\n", (unsigned long) tz->leapcnt);
printf("Trans. count: %lu\n", (unsigned long) tz->timecnt);
printf("Local types count: %lu\n", (unsigned long) tz->typecnt);
printf("Zone Abbr. count: %lu\n", (unsigned long) tz->charcnt);
printf ("%8s (%12s) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n",
"", "", 0,
@@ -277,7 +237,7 @@ void timelib_dump_tzinfo(timelib_tzinfo *tz)
tz->type[0].isstdcnt,
tz->type[0].isgmtcnt
);
for (i = 0; i < tz->bit32.timecnt; i++) {
for (i = 0; i < tz->timecnt; i++) {
printf ("%08X (%12d) = %3d [%5ld %1d %3d '%s' (%d,%d)]\n",
tz->trans[i], tz->trans[i], tz->trans_idx[i],
(long int) tz->type[tz->trans_idx[i]].offset,
@@ -288,7 +248,7 @@ void timelib_dump_tzinfo(timelib_tzinfo *tz)
tz->type[tz->trans_idx[i]].isgmtcnt
);
}
for (i = 0; i < tz->bit32.leapcnt; i++) {
for (i = 0; i < tz->leapcnt; i++) {
printf ("%08X (%12ld) = %d\n",
tz->leap_times[i].trans,
(long) tz->leap_times[i].trans,
@@ -307,7 +267,7 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const
cur_locale = strdup(tmp);
}
setlocale(LC_CTYPE, "C");
#endif
#endif
do {
int mid = ((unsigned)left + right) >> 1;
@@ -322,7 +282,7 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const
#ifdef HAVE_SETLOCALE
setlocale(LC_CTYPE, cur_locale);
if (cur_locale) free(cur_locale);
#endif
#endif
return 1;
}
@@ -331,7 +291,7 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const
#ifdef HAVE_SETLOCALE
setlocale(LC_CTYPE, cur_locale);
if (cur_locale) free(cur_locale);
#endif
#endif
return 0;
}
@@ -352,45 +312,18 @@ int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb)
return (seek_to_tz_position(&tzf, timezone, tzdb));
}
static void skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
{
*tzf += 20;
}
static void read_64bit_header(const unsigned char **tzf, timelib_tzinfo *tz)
{
uint32_t buffer[6];
memcpy(&buffer, *tzf, sizeof(buffer));
tz->bit64.ttisgmtcnt = timelib_conv_int(buffer[0]);
tz->bit64.ttisstdcnt = timelib_conv_int(buffer[1]);
tz->bit64.leapcnt = timelib_conv_int(buffer[2]);
tz->bit64.timecnt = timelib_conv_int(buffer[3]);
tz->bit64.typecnt = timelib_conv_int(buffer[4]);
tz->bit64.charcnt = timelib_conv_int(buffer[5]);
*tzf += sizeof(buffer);
}
timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb)
{
const unsigned char *tzf;
timelib_tzinfo *tmp;
int version;
if (seek_to_tz_position(&tzf, timezone, tzdb)) {
tmp = timelib_tzinfo_ctor(timezone);
version = read_preamble(&tzf, tmp);
read_preamble(&tzf, tmp);
read_header(&tzf, tmp);
read_transistions(&tzf, tmp);
read_types(&tzf, tmp);
if (version == 2) {
skip_64bit_preamble(&tzf, tmp);
read_64bit_header(&tzf, tmp);
skip_64bit_transistions(&tzf, tmp);
skip_64bit_types(&tzf, tmp);
skip_posix_string(&tzf, tmp);
}
read_location(&tzf, tmp);
} else {
tmp = NULL;
@@ -405,9 +338,9 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib
/* If there is no transition time, we pick the first one, if that doesn't
* exist we return NULL */
if (!tz->bit32.timecnt || !tz->trans) {
if (!tz->timecnt || !tz->trans) {
*transition_time = 0;
if (tz->bit32.typecnt == 1) {
if (tz->typecnt == 1) {
return &(tz->type[0]);
}
return NULL;
@@ -422,10 +355,10 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib
*transition_time = 0;
j = 0;
while (j < tz->bit32.timecnt && tz->type[j].isdst) {
while (j < tz->timecnt && tz->type[j].isdst) {
++j;
}
if (j == tz->bit32.timecnt) {
if (j == tz->timecnt) {
j = 0;
}
return &(tz->type[j]);
@@ -433,25 +366,25 @@ static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib
/* In all other cases we loop through the available transtion times to find
* the correct entry */
for (i = 0; i < tz->bit32.timecnt; i++) {
for (i = 0; i < tz->timecnt; i++) {
if (ts < tz->trans[i]) {
*transition_time = tz->trans[i - 1];
return &(tz->type[tz->trans_idx[i - 1]]);
}
}
*transition_time = tz->trans[tz->bit32.timecnt - 1];
return &(tz->type[tz->trans_idx[tz->bit32.timecnt - 1]]);
*transition_time = tz->trans[tz->timecnt - 1];
return &(tz->type[tz->trans_idx[tz->timecnt - 1]]);
}
static tlinfo* fetch_leaptime_offset(timelib_tzinfo *tz, timelib_sll ts)
{
int i;
if (!tz->bit32.leapcnt || !tz->leap_times) {
if (!tz->leapcnt || !tz->leap_times) {
return NULL;
}
for (i = tz->bit32.leapcnt - 1; i > 0; i--) {
for (i = tz->leapcnt - 1; i > 0; i--) {
if (ts > tz->leap_times[i].trans) {
return &(tz->leap_times[i]);
}
@@ -463,7 +396,7 @@ int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz)
{
ttinfo *to;
timelib_sll dummy;
if ((to = fetch_timezone_offset(tz, ts, &dummy))) {
return to->isdst;
}
@@ -506,12 +439,12 @@ timelib_sll timelib_get_current_offset(timelib_time *t)
{
timelib_time_offset *gmt_offset;
timelib_sll retval;
switch (t->zone_type) {
case TIMELIB_ZONETYPE_ABBR:
case TIMELIB_ZONETYPE_OFFSET:
return (t->z + t->dst) * -60;
case TIMELIB_ZONETYPE_ID:
gmt_offset = timelib_get_time_zone_info(t->sse, t->tz_info);
retval = gmt_offset->offset;
+19 -19
View File
@@ -116,26 +116,26 @@ timelib_tzinfo* timelib_tzinfo_ctor(char *name)
timelib_tzinfo *timelib_tzinfo_clone(timelib_tzinfo *tz)
{
timelib_tzinfo *tmp = timelib_tzinfo_ctor(tz->name);
tmp->bit32.ttisgmtcnt = tz->bit32.ttisgmtcnt;
tmp->bit32.ttisstdcnt = tz->bit32.ttisstdcnt;
tmp->bit32.leapcnt = tz->bit32.leapcnt;
tmp->bit32.timecnt = tz->bit32.timecnt;
tmp->bit32.typecnt = tz->bit32.typecnt;
tmp->bit32.charcnt = tz->bit32.charcnt;
tmp->ttisgmtcnt = tz->ttisgmtcnt;
tmp->ttisstdcnt = tz->ttisstdcnt;
tmp->leapcnt = tz->leapcnt;
tmp->timecnt = tz->timecnt;
tmp->typecnt = tz->typecnt;
tmp->charcnt = tz->charcnt;
tmp->trans = (int32_t *) malloc(tz->timecnt * sizeof(int32_t));
tmp->trans_idx = (unsigned char*) malloc(tz->timecnt * sizeof(unsigned char));
memcpy(tmp->trans, tz->trans, tz->timecnt * sizeof(int32_t));
memcpy(tmp->trans_idx, tz->trans_idx, tz->timecnt * sizeof(unsigned char));
tmp->trans = (int32_t *) malloc(tz->bit32.timecnt * sizeof(int32_t));
tmp->trans_idx = (unsigned char*) malloc(tz->bit32.timecnt * sizeof(unsigned char));
memcpy(tmp->trans, tz->trans, tz->bit32.timecnt * sizeof(int32_t));
memcpy(tmp->trans_idx, tz->trans_idx, tz->bit32.timecnt * sizeof(unsigned char));
tmp->type = (ttinfo*) malloc(tz->typecnt * sizeof(struct ttinfo));
memcpy(tmp->type, tz->type, tz->typecnt * sizeof(struct ttinfo));
tmp->type = (ttinfo*) malloc(tz->bit32.typecnt * sizeof(struct ttinfo));
memcpy(tmp->type, tz->type, tz->bit32.typecnt * sizeof(struct ttinfo));
tmp->timezone_abbr = (char*) malloc(tz->charcnt);
memcpy(tmp->timezone_abbr, tz->timezone_abbr, tz->charcnt);
tmp->timezone_abbr = (char*) malloc(tz->bit32.charcnt);
memcpy(tmp->timezone_abbr, tz->timezone_abbr, tz->bit32.charcnt);
tmp->leap_times = (tlinfo*) malloc(tz->bit32.leapcnt * sizeof(tlinfo));
memcpy(tmp->leap_times, tz->leap_times, tz->bit32.leapcnt * sizeof(tlinfo));
tmp->leap_times = (tlinfo*) malloc(tz->leapcnt * sizeof(tlinfo));
memcpy(tmp->leap_times, tz->leap_times, tz->leapcnt * sizeof(tlinfo));
return tmp;
}
@@ -236,7 +236,7 @@ void timelib_dump_date(timelib_time *d, int options)
if ((options & 1) == 1) {
if (d->have_relative) {
printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS",
printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS",
d->relative.y, d->relative.m, d->relative.d, d->relative.h, d->relative.i, d->relative.s);
if (d->relative.first_last_day_of != 0) {
switch (d->relative.first_last_day_of) {
@@ -271,7 +271,7 @@ void timelib_dump_date(timelib_time *d, int options)
void timelib_dump_rel_time(timelib_rel_time *d)
{
printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS (days: %lld)%s",
printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS (days: %lld)%s",
d->y, d->m, d->d, d->h, d->i, d->s, d->days, d->invert ? " inverted" : "");
if (d->first_last_day_of != 0) {
switch (d->first_last_day_of) {
+2 -2
View File
@@ -80,8 +80,8 @@ long timelib_parse_tz_cor(char**);
/* From parse_iso_intervals.re */
void timelib_strtointerval(char *s, int len,
timelib_time **begin, timelib_time **end,
timelib_rel_time **period, int *recurrences,
timelib_time **begin, timelib_time **end,
timelib_rel_time **period, int *recurrences,
struct timelib_error_container **errors);
+6 -16
View File
@@ -158,22 +158,12 @@ typedef struct tlocinfo
typedef struct timelib_tzinfo
{
char *name;
struct {
uint32_t ttisgmtcnt;
uint32_t ttisstdcnt;
uint32_t leapcnt;
uint32_t timecnt;
uint32_t typecnt;
uint32_t charcnt;
} bit32;
struct {
uint64_t ttisgmtcnt;
uint64_t ttisstdcnt;
uint64_t leapcnt;
uint64_t timecnt;
uint64_t typecnt;
uint64_t charcnt;
} bit64;
uint32_t ttisgmtcnt;
uint32_t ttisstdcnt;
uint32_t leapcnt;
uint32_t timecnt;
uint32_t typecnt;
uint32_t charcnt;
int32_t *trans;
unsigned char *trans_idx;
+16513 -43595
View File
File diff suppressed because it is too large. Load diff
+4 -4
View File
@@ -106,7 +106,7 @@ static int do_range_limit_days(timelib_sll *y, timelib_sll *m, timelib_sll *d)
timelib_sll days_this_month;
timelib_sll last_month, last_year;
timelib_sll days_last_month;
/* can jump an entire leap year period quickly */
if (*d >= DAYS_PER_LYEAR_PERIOD || *d <= -DAYS_PER_LYEAR_PERIOD) {
*y += YEARS_PER_LYEAR_PERIOD * (*d / DAYS_PER_LYEAR_PERIOD);
@@ -396,7 +396,7 @@ static timelib_sll do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
timelib_time_offset *before, *after;
timelib_sll tmp;
int in_transistion;
tz->is_localtime = 1;
before = timelib_get_time_zone_info(tz->sse, tzi);
after = timelib_get_time_zone_info(tz->sse - before->offset, tzi);
@@ -406,7 +406,7 @@ static timelib_sll do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
((tz->sse - after->offset) >= (after->transistion_time + (before->offset - after->offset))) &&
((tz->sse - after->offset) < after->transistion_time)
);
if ((before->offset != after->offset) && !in_transistion) {
tmp = -after->offset;
} else {
@@ -464,7 +464,7 @@ int main(void)
printf ("%04d-%02d-%02d %02d:%02d:%02d.%-5d %+04d %1d",
time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
if (time.have_relative) {
printf ("%3dY %3dM %3dD / %3dH %3dM %3dS",
printf ("%3dY %3dM %3dD / %3dH %3dM %3dS",
time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative.s);
}
if (time.have_weekday_relative) {
+5 -5
View File
@@ -141,7 +141,7 @@ void timelib_update_from_sse(timelib_time *tm)
signed int dst = tm->dst;
sse = tm->sse;
switch (tm->zone_type) {
case TIMELIB_ZONETYPE_ABBR:
case TIMELIB_ZONETYPE_OFFSET: {
@@ -152,11 +152,11 @@ void timelib_update_from_sse(timelib_time *tm)
case TIMELIB_ZONETYPE_ID: {
timelib_time_offset *gmt_offset;
gmt_offset = timelib_get_time_zone_info(tm->sse, tm->tz_info);
timelib_unixtime2gmt(tm, tm->sse + gmt_offset->offset);
timelib_time_offset_dtor(gmt_offset);
goto cleanup;
}
@@ -182,7 +182,7 @@ void timelib_unixtime2local(timelib_time *tm, timelib_sll ts)
case TIMELIB_ZONETYPE_OFFSET: {
int z = tm->z;
signed int dst = tm->dst;
timelib_unixtime2gmt(tm, ts - (tm->z * 60) + (tm->dst * 3600));
tm->z = z;
@@ -195,7 +195,7 @@ void timelib_unixtime2local(timelib_time *tm, timelib_sll ts)
timelib_unixtime2gmt(tm, ts + gmt_offset->offset);
/* we need to reset the sse here as unixtime2gmt modifies it */
tm->sse = ts;
tm->sse = ts;
tm->dst = gmt_offset->is_dst;
tm->z = gmt_offset->offset;
tm->tz_info = tz;
+5 -9
View File
@@ -885,10 +885,6 @@ PHP_MSHUTDOWN_FUNCTION(date)
timelib_error_container_dtor(DATEG(last_errors));
}
#ifndef ZTS
DATEG(default_timezone) = NULL;
#endif
return SUCCESS;
}
/* }}} */
@@ -3930,7 +3926,7 @@ PHP_FUNCTION(timezone_transitions_get)
add_assoc_string(element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].abbr_idx], 1); \
add_next_index_zval(return_value, element);
#define add_last() add(tzobj->tzi.tz->bit32.timecnt - 1, timestamp_begin)
#define add_last() add(tzobj->tzi.tz->timecnt - 1, timestamp_begin)
array_init(return_value);
@@ -3941,7 +3937,7 @@ PHP_FUNCTION(timezone_transitions_get)
} else {
begin = 0;
found = 0;
if (tzobj->tzi.tz->bit32.timecnt > 0) {
if (tzobj->tzi.tz->timecnt > 0) {
do {
if (tzobj->tzi.tz->trans[begin] > timestamp_begin) {
if (begin > 0) {
@@ -3953,18 +3949,18 @@ PHP_FUNCTION(timezone_transitions_get)
break;
}
begin++;
} while (begin < tzobj->tzi.tz->bit32.timecnt);
} while (begin < tzobj->tzi.tz->timecnt);
}
}
if (!found) {
if (tzobj->tzi.tz->bit32.timecnt > 0) {
if (tzobj->tzi.tz->timecnt > 0) {
add_last();
} else {
add_nominal();
}
} else {
for (i = begin; i < tzobj->tzi.tz->bit32.timecnt; ++i) {
for (i = begin; i < tzobj->tzi.tz->timecnt; ++i) {
if (tzobj->tzi.tz->trans[i] < timestamp_end) {
add(i, tzobj->tzi.tz->trans[i]);
}
@@ -16,7 +16,7 @@ date_default_timezone_set("Europe/London");
// Create a DateTimeZone object
$tz = new DateTimeZone("Europe/London");
$tran = $tz->getTransitions(-306972000, -37241999);
$tran = $tz->getTransitions();
if (!is_array($tran)) {
echo "TEST FAILED: Expected an array\n";
@@ -25,14 +25,14 @@ if (!is_array($tran)) {
echo "\n-- Total number of transitions: " . count($tran). " --\n";
echo "\n-- Format a sample entry for Spring 1963 --\n";
var_dump( $tran[6] );
var_dump( $tran[97] );
?>
===DONE===
--EXPECT--
*** Testing DateTimeZone::getTransitions() : basic functionality ***
-- Total number of transitions: 18 --
-- Total number of transitions: 243 --
-- Format a sample entry for Spring 1963 --
array(5) {
+3 -3
View File
@@ -10,6 +10,6 @@ define('PHPT_DATETIME_SHOW', PHPT_DATETIME_SHOW_ADD);
require 'DateTime_data-massive.inc';
?>
--EXPECTF--
test_massive_positive: ADD: -333333-01-01 16:18:02 %s + P+666666Y0M0DT0H0M0S = **333333-01-01 16:18:02 %s**
test_massive_negative: ADD: 333333-01-01 16:18:02 %s + P-666666Y0M0DT0H0M0S = **-333333-01-01 16:18:02 %s**
--EXPECT--
test_massive_positive: ADD: -333333-01-01 16:18:02 EST + P+666666Y0M0DT0H0M0S = **333333-01-01 16:18:02 EST**
test_massive_negative: ADD: 333333-01-01 16:18:02 EST + P-666666Y0M0DT0H0M0S = **-333333-01-01 16:18:02 EST**
+3 -3
View File
@@ -10,6 +10,6 @@ define('PHPT_DATETIME_SHOW', PHPT_DATETIME_SHOW_DIFF);
require 'DateTime_data-massive.inc';
?>
--EXPECTF--
test_massive_positive: DIFF: 333333-01-01 16:18:02 %s - -333333-01-01 16:18:02 %s = **P+666666Y0M0DT0H%s**
test_massive_negative: DIFF: -333333-01-01 16:18:02 %s - 333333-01-01 16:18:02 %s = **P-666666Y0M0DT0H%s**
--EXPECT--
test_massive_positive: DIFF: 333333-01-01 16:18:02 EST - -333333-01-01 16:18:02 EST = **P+666666Y0M0DT0H0M0S**
test_massive_negative: DIFF: -333333-01-01 16:18:02 EST - 333333-01-01 16:18:02 EST = **P-666666Y0M0DT0H0M0S**
+3 -3
View File
@@ -10,6 +10,6 @@ define('PHPT_DATETIME_SHOW', PHPT_DATETIME_SHOW_SUB);
require 'DateTime_data-massive.inc';
?>
--EXPECTF--
test_massive_positive: SUB: 333333-01-01 16:18:02 %s - P+666666Y0M0DT0H0M0S = **-333333-01-01 16:18:02 %s**
test_massive_negative: SUB: -333333-01-01 16:18:02 %s - P-666666Y0M0DT0H0M0S = **333333-01-01 16:18:02 %s**
--EXPECT--
test_massive_positive: SUB: 333333-01-01 16:18:02 EST - P+666666Y0M0DT0H0M0S = **-333333-01-01 16:18:02 EST**
test_massive_negative: SUB: -333333-01-01 16:18:02 EST - P-666666Y0M0DT0H0M0S = **333333-01-01 16:18:02 EST**
+3 -3
View File
@@ -20,10 +20,10 @@ array(5) {
["time"]=>
string(%d) "%s"
["offset"]=>
int(%s)
int(3600)
["isdst"]=>
bool(%s)
bool(true)
["abbr"]=>
string(%d) "%s"
string(3) "BST"
}
10000002008-02-28T12:00:00+0000
+4 -4
View File
@@ -27,7 +27,7 @@ var_dump( getdate($timestamp) );
-- Testing getdate\(\) function by passing float 12.3456789000e10 value to timestamp --
array\(11\) {
\["seconds"\]=>
int\((.+)\)
int\((36|0)\)
\["minutes"\]=>
int\((43|0)\)
\["hours"\]=>
@@ -53,7 +53,7 @@ array\(11\) {
-- Testing getdate\(\) function by passing float -12.3456789000e10 value to timestamp --
array\(11\) {
\["seconds"\]=>
int\((.+)\)
int\((44|12|20)\)
\["minutes"\]=>
int\((39|23)\)
\["hours"\]=>
@@ -61,7 +61,7 @@ array\(11\) {
\["mday"\]=>
int\((9|14|23)\)
\["wday"\]=>
int\((0|6)\)
int\(0\)
\["mon"\]=>
int\((10|12)\)
\["year"\]=>
@@ -69,7 +69,7 @@ array\(11\) {
\["yday"\]=>
int\((282|347|295)\)
\["weekday"\]=>
string\((6|8)\) "(Sunday|Saturday)"
string\(6\) "Sunday"
\["month"\]=>
string\((7|8)\) "(October|December)"
\[0\]=>
+2 -2
View File
@@ -87,7 +87,7 @@ array\(9\) {
\[5\]=>
int\((104|1|-3843)\)
\[6\]=>
int\((5|6)\)
int\(6\)
\[7\]=>
int\((281|346|294)\)
\[8\]=>
@@ -107,7 +107,7 @@ array\(9\) {
\["tm_year"\]=>
int\((104|1|-3843)\)
\["tm_wday"\]=>
int\((5|6)\)
int\(6\)
\["tm_yday"\]=>
int\((281|346|294)\)
\["tm_isdst"\]=>
+11 -11
View File
@@ -24,7 +24,7 @@ foreach ($tzs as $tz) {
echo "\n";
}
?>
--EXPECTF--
--EXPECT--
America/Toronto
Y: 0 - January 2000-01-01T01:01:01-0500
Y: 69 - January 2069-01-01T01:01:01-0500
@@ -32,11 +32,11 @@ Y: 70 - January 1970-01-01T01:01:01-0500
Y: 71 - January 1971-01-01T01:01:01-0500
Y: 99 - January 1999-01-01T01:01:01-0500
Y: 100 - January 2000-01-01T01:01:01-0500
Y: 101 - January 0101-01-01T01:01:01-0%d
Y: 105 - January 0105-01-01T01:01:01-0%d
Y: 110 - January 0110-01-01T01:01:01-0%d
Y: 1900 - January 1900-01-01T01:01:01-0%d
Y: 1901 - January 1901-01-01T01:01:01-0%d
Y: 101 - January 0101-01-01T01:01:01-0500
Y: 105 - January 0105-01-01T01:01:01-0500
Y: 110 - January 0110-01-01T01:01:01-0500
Y: 1900 - January 1900-01-01T01:01:01-0500
Y: 1901 - January 1901-01-01T01:01:01-0500
Y: 1902 - January 1902-01-01T01:01:01-0500
Y: 1999 - January 1999-01-01T01:01:01-0500
Y: 2000 - January 2000-01-01T01:01:01-0500
@@ -49,11 +49,11 @@ Y: 70 - January 1970-01-01T01:01:01+0100
Y: 71 - January 1971-01-01T01:01:01+0100
Y: 99 - January 1999-01-01T01:01:01+0100
Y: 100 - January 2000-01-01T01:01:01+0100
Y: 101 - January 0101-01-01T01:01:01+0%d
Y: 105 - January 0105-01-01T01:01:01+0%d
Y: 110 - January 0110-01-01T01:01:01+0%d
Y: 1900 - January 1900-01-01T01:01:01+0%d
Y: 1901 - January 1901-01-01T01:01:01+0%d
Y: 101 - January 0101-01-01T01:01:01+0100
Y: 105 - January 0105-01-01T01:01:01+0100
Y: 110 - January 0110-01-01T01:01:01+0100
Y: 1900 - January 1900-01-01T01:01:01+0100
Y: 1901 - January 1901-01-01T01:01:01+0100
Y: 1902 - January 1902-01-01T01:01:01+0100
Y: 1999 - January 1999-01-01T01:01:01+0100
Y: 2000 - January 2000-01-01T01:01:01+0100
@@ -18,24 +18,24 @@ $tz = timezone_open("Europe/London");
$tran = timezone_transitions_get($tz);
echo "\n-- Get all 60s transitions --\n";
$tran = timezone_transitions_get($tz, -306972000, -37241999);
echo "\n-- Get all transitions --\n";
$tran = timezone_transitions_get($tz);
var_dump( gettype($tran) );
echo "\n-- Total number of transitions: " . count($tran). " --\n";
echo "\n-- Format a sample entry pfor Spring 1963 --\n";
var_dump( $tran[6] );
var_dump( $tran[97] );
?>
===DONE===
--EXPECT--
*** Testing timezone_transitions_get() : basic functionality ***
-- Get all 60s transitions --
-- Get all transitions --
string(5) "array"
-- Total number of transitions: 18 --
-- Total number of transitions: 243 --
-- Format a sample entry pfor Spring 1963 --
array(5) {
+1 -1
View File
@@ -914,7 +914,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
RETURN_FALSE;
#ifdef F_SETFL
} else if (modenr == DBA_CREAT) {
int flags = fcntl(info->fd, F_GETFL);
int flags = fcntl(info->fd, F_SETFL);
fcntl(info->fd, F_SETFL, flags & ~O_APPEND);
#endif
}
+5 -17
View File
@@ -1700,7 +1700,7 @@ PHP_FUNCTION(dom_document_save)
char *file;
long options = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
return;
}
@@ -1930,7 +1930,7 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type
int is_valid;
char resolved_path[MAXPATHLEN + 1];
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &id, dom_document_class_entry, &source, &source_len, &flags) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op|l", &id, dom_document_class_entry, &source, &source_len, &flags) == FAILURE) {
return;
}
@@ -1943,10 +1943,6 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type
switch (type) {
case DOM_LOAD_FILE:
if (CHECK_NULL_PATH(source, source_len)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Schema file source");
RETURN_FALSE;
}
valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
if (!valid_file) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Schema file source");
@@ -2030,7 +2026,7 @@ static void _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int typ
int is_valid;
char resolved_path[MAXPATHLEN + 1];
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
return;
}
@@ -2043,10 +2039,6 @@ static void _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int typ
switch (type) {
case DOM_LOAD_FILE:
if (CHECK_NULL_PATH(source, source_len)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid RelaxNG file source");
RETURN_FALSE;
}
valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
if (!valid_file) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid RelaxNG file source");
@@ -2127,7 +2119,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
id = getThis();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) {
return;
}
@@ -2137,10 +2129,6 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
}
if (mode == DOM_LOAD_FILE) {
if (CHECK_NULL_PATH(source, source_len)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid file source");
RETURN_FALSE;
}
ctxt = htmlCreateFileParserCtxt(source, NULL);
} else {
source_len = xmlStrlen(source);
@@ -2229,7 +2217,7 @@ PHP_FUNCTION(dom_document_save_html_file)
char *file;
const char *encoding;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op", &id, dom_document_class_entry, &file, &file_len) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &file, &file_len) == FAILURE) {
return;
}
@@ -15,9 +15,9 @@ $result = $doc->loadHTMLFile("");
assert('$result === false');
$doc = new DOMDocument();
$result = $doc->loadHTMLFile("text.html\0something");
assert('$result === false');
assert('$result === null');
?>
--EXPECTF--
%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Empty string supplied as input %s
%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Invalid file source %s
%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile() expects parameter 1 to be a valid path, string given %s
+1 -1
View File
@@ -1,5 +1,5 @@
--TEST--
Bug #68799 (Free called on uninitialized pointer)
Bug #68799 (Free called on unitialized pointer)
--SKIPIF--
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
--FILE--
+1 -1
View File
@@ -29,6 +29,6 @@ string(28) "text/x-php; charset=us-ascii"
string(22) "PHP script, ASCII text"
string(25) "text/plain; charset=utf-8"
Warning: finfo_file(): Invalid path in %s%efinfo_file_basic.php on line %d
Warning: finfo_file(): Invalid path in %s/finfo_file_basic.php on line %d
bool(false)
===DONE===
+43 -41
View File
@@ -188,9 +188,9 @@ ftp_close(ftpbuf_t *ftp)
SSL_shutdown(ftp->ssl_handle);
SSL_free(ftp->ssl_handle);
}
#endif
#endif
closesocket(ftp->fd);
}
}
ftp_gc(ftp);
efree(ftp);
return NULL;
@@ -262,7 +262,7 @@ ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
if (!ftp_getresp(ftp)) {
return 0;
}
if (ftp->resp != 234) {
if (!ftp_putcmd(ftp, "AUTH", "SSL")) {
return 0;
@@ -270,7 +270,7 @@ ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
if (!ftp_getresp(ftp)) {
return 0;
}
if (ftp->resp != 334) {
return 0;
} else {
@@ -278,7 +278,7 @@ ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
ftp->use_ssl_for_data = 1;
}
}
ctx = SSL_CTX_new(SSLv23_client_method());
if (ctx == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to create the SSL context");
@@ -325,8 +325,8 @@ ftp_login(ftpbuf_t *ftp, const char *user, const char *pass TSRMLS_DC)
if (!ftp_getresp(ftp)) {
return 0;
}
ftp->use_ssl_for_data = (ftp->resp >= 200 && ftp->resp <=299);
ftp->use_ssl_for_data = (ftp->resp >= 200 && ftp->resp <=299);
}
}
#endif
@@ -360,7 +360,7 @@ ftp_reinit(ftpbuf_t *ftp)
{
if (ftp == NULL) {
return 0;
}
}
ftp_gc(ftp);
@@ -395,7 +395,7 @@ ftp_syst(ftpbuf_t *ftp)
if (!ftp_putcmd(ftp, "SYST", NULL)) {
return NULL;
}
if (!ftp_getresp(ftp) || ftp->resp != 215) {
if (!ftp_getresp(ftp) || ftp->resp != 215) {
return NULL;
}
syst = ftp->inbuf;
@@ -431,14 +431,14 @@ ftp_pwd(ftpbuf_t *ftp)
if (!ftp_putcmd(ftp, "PWD", NULL)) {
return NULL;
}
if (!ftp_getresp(ftp) || ftp->resp != 257) {
if (!ftp_getresp(ftp) || ftp->resp != 257) {
return NULL;
}
/* copy out the pwd from response */
if ((pwd = strchr(ftp->inbuf, '"')) == NULL) {
if ((pwd = strchr(ftp->inbuf, '"')) == NULL) {
return NULL;
}
if ((end = strrchr(++pwd, '"')) == NULL) {
if ((end = strrchr(++pwd, '"')) == NULL) {
return NULL;
}
ftp->pwd = estrndup(pwd, end - pwd);
@@ -608,7 +608,7 @@ ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filenam
if (!ftp_getresp(ftp) || ftp->resp != 200) {
return 0;
}
return 1;
}
/* }}} */
@@ -625,7 +625,7 @@ ftp_alloc(ftpbuf_t *ftp, const long size, char **response)
}
snprintf(buffer, sizeof(buffer) - 1, "%ld", size);
if (!ftp_putcmd(ftp, "ALLO", buffer)) {
return 0;
}
@@ -642,7 +642,7 @@ ftp_alloc(ftpbuf_t *ftp, const long size, char **response)
return 0;
}
return 1;
return 1;
}
/* }}} */
@@ -674,7 +674,7 @@ ftp_type(ftpbuf_t *ftp, ftptype_t type)
if (ftp == NULL) {
return 0;
}
if (type == ftp->type) {
if (type == ftp->type) {
return 1;
}
if (type == FTPTYPE_ASCII) {
@@ -765,7 +765,7 @@ ftp_pasv(ftpbuf_t *ftp, int pasv)
if (!ftp_putcmd(ftp, "PASV", NULL)) {
return 0;
}
if (!ftp_getresp(ftp) || ftp->resp != 227) {
if (!ftp_getresp(ftp) || ftp->resp != 227) {
return 0;
}
/* parse out the IP and port */
@@ -807,7 +807,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type,
if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {
goto bail;
}
ftp->data = data;
if (resumepos > 0) {
@@ -900,7 +900,7 @@ ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, l
if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {
goto bail;
}
ftp->data = data;
ftp->data = data;
if (startpos > 0) {
snprintf(arg, sizeof(arg), "%ld", startpos);
@@ -1101,7 +1101,7 @@ ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char *args)
if (strpbrk(cmd, "\r\n")) {
return 0;
}
}
/* build the output buffer */
if (args && args[0]) {
/* "cmd args\r\n\0" */
@@ -1247,7 +1247,7 @@ my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
#if HAVE_OPENSSL_EXT
if (ftp->use_ssl && ftp->fd == s && ftp->ssl_active) {
sent = SSL_write(ftp->ssl_handle, buf, size);
} else if (ftp->use_ssl && ftp->fd != s && ftp->use_ssl_for_data && ftp->data->ssl_active) {
} else if (ftp->use_ssl && ftp->fd != s && ftp->use_ssl_for_data && ftp->data->ssl_active) {
sent = SSL_write(ftp->data->ssl_handle, buf, size);
} else {
#endif
@@ -1287,14 +1287,14 @@ my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
#if HAVE_OPENSSL_EXT
if (ftp->use_ssl && ftp->fd == s && ftp->ssl_active) {
nr_bytes = SSL_read(ftp->ssl_handle, buf, len);
} else if (ftp->use_ssl && ftp->fd != s && ftp->use_ssl_for_data && ftp->data->ssl_active) {
} else if (ftp->use_ssl && ftp->fd != s && ftp->use_ssl_for_data && ftp->data->ssl_active) {
nr_bytes = SSL_read(ftp->data->ssl_handle, buf, len);
} else {
#endif
nr_bytes = recv(s, buf, len, 0);
#if HAVE_OPENSSL_EXT
}
#endif
#endif
return (nr_bytes);
}
/* }}} */
@@ -1511,7 +1511,7 @@ data_accept(databuf_t *data, ftpbuf_t *ftp TSRMLS_DC)
data_accepted:
#if HAVE_OPENSSL_EXT
/* now enable ssl if we need to */
if (ftp->use_ssl && ftp->use_ssl_for_data) {
ctx = SSL_CTX_new(SSLv23_client_method());
@@ -1531,23 +1531,23 @@ data_accepted:
SSL_CTX_free(ctx);
return 0;
}
SSL_set_fd(data->ssl_handle, data->fd);
if (ftp->old_ssl) {
SSL_copy_session_id(data->ssl_handle, ftp->ssl_handle);
}
if (SSL_connect(data->ssl_handle) <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "data_accept: SSL/TLS handshake failed");
SSL_shutdown(data->ssl_handle);
SSL_free(data->ssl_handle);
return 0;
}
data->ssl_active = 1;
}
}
#endif
@@ -1562,14 +1562,14 @@ data_close(ftpbuf_t *ftp, databuf_t *data)
{
#if HAVE_OPENSSL_EXT
SSL_CTX *ctx;
#endif
#endif
if (data == NULL) {
return NULL;
}
if (data->listener != -1) {
#if HAVE_OPENSSL_EXT
if (data->ssl_active) {
ctx = SSL_get_SSL_CTX(data->ssl_handle);
SSL_CTX_free(ctx);
@@ -1577,9 +1577,9 @@ data_close(ftpbuf_t *ftp, databuf_t *data)
SSL_free(data->ssl_handle);
data->ssl_active = 0;
}
#endif
#endif
closesocket(data->listener);
}
}
if (data->fd != -1) {
#if HAVE_OPENSSL_EXT
if (data->ssl_active) {
@@ -1590,9 +1590,9 @@ data_close(ftpbuf_t *ftp, databuf_t *data)
SSL_free(data->ssl_handle);
data->ssl_active = 0;
}
#endif
#endif
closesocket(data->fd);
}
}
if (ftp) {
ftp->data = NULL;
}
@@ -1610,8 +1610,8 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
databuf_t *data = NULL;
char *ptr;
int ch, lastch;
size_t size, rcvd;
size_t lines;
int size, rcvd;
int lines;
char **ret = NULL;
char **entry;
char *text;
@@ -1629,7 +1629,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
if ((data = ftp_getdata(ftp TSRMLS_CC)) == NULL) {
goto bail;
}
ftp->data = data;
ftp->data = data;
if (!ftp_putcmd(ftp, cmd, path)) {
goto bail;
@@ -1653,7 +1653,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
lines = 0;
lastch = 0;
while ((rcvd = my_recv(ftp, data->fd, data->buf, FTP_BUFSIZE))) {
if (rcvd == -1 || rcvd > ((size_t)(-1))-size) {
if (rcvd == -1) {
goto bail;
}
@@ -1663,6 +1663,8 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
for (ptr = data->buf; rcvd; rcvd--, ptr++) {
if (*ptr == '\n' && lastch == '\r') {
lines++;
} else {
size++;
}
lastch = *ptr;
}
@@ -1856,7 +1858,7 @@ ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type
if (!ftp_getresp(ftp) || (ftp->resp != 150 && ftp->resp != 125)) {
goto bail;
}
if ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) {
if ((data = data_accept(data, ftp TSRMLS_CC)) == NULL) {
goto bail;
}
ftp->data = data;
@@ -1912,7 +1914,7 @@ ftp_nb_continue_write(ftpbuf_t *ftp TSRMLS_DC)
goto bail;
}
ftp->data = data_close(ftp, ftp->data);
if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) {
goto bail;
}
+8 -9
View File
@@ -1750,7 +1750,7 @@ PHP_FUNCTION(imagefilledarc)
long cx, cy, w, h, ST, E, col, style;
gdImagePtr im;
int e, st;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllllllll", &IM, &cx, &cy, &w, &h, &ST, &E, &col, &style) == FAILURE) {
return;
}
@@ -1991,7 +1991,7 @@ PHP_FUNCTION(imagegrabwindow)
if ( handle == 0 ) {
goto clean;
}
pPrintWindow = (tPrintWindow) GetProcAddress(handle, "PrintWindow");
pPrintWindow = (tPrintWindow) GetProcAddress(handle, "PrintWindow");
if ( pPrintWindow ) {
pPrintWindow(window, memDC, (UINT) client_area);
@@ -3060,11 +3060,10 @@ PHP_FUNCTION(imagegammacorrect)
for (x = 0; x < gdImageSX(im); x++) {
c = gdImageGetPixel(im, x, y);
gdImageSetPixel(im, x, y,
gdTrueColorAlpha(
gdTrueColor(
(int) ((pow((pow((gdTrueColorGetRed(c) / 255.0), input)), 1.0 / output) * 255) + .5),
(int) ((pow((pow((gdTrueColorGetGreen(c) / 255.0), input)), 1.0 / output) * 255) + .5),
(int) ((pow((pow((gdTrueColorGetBlue(c) / 255.0), input)), 1.0 / output) * 255) + .5),
gdTrueColorGetAlpha(c)
(int) ((pow((pow((gdTrueColorGetBlue(c) / 255.0), input)), 1.0 / output) * 255) + .5)
)
);
}
@@ -3861,7 +3860,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
if (zend_hash_get_current_data_ex(HASH_OF(EXT), (void **) &item, &pos) == FAILURE) {
continue;
}
if (strcmp("linespacing", key) == 0) {
convert_to_double_ex(item);
strex.flags |= gdFTEX_LINESPACE;
@@ -3940,7 +3939,7 @@ PHP_FUNCTION(imagepsloadfont)
struct stat st;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &file, &file_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
return;
}
@@ -4280,11 +4279,11 @@ PHP_FUNCTION(imagepsbbox)
if (argc != 3 && argc != 6) {
ZEND_WRONG_PARAM_COUNT();
}
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "srl|lld", &str, &str_len, &fnt, &sz, &sp, &wd, &angle) == FAILURE) {
return;
}
if (argc == 6) {
space = sp;
add_width = wd;
+7 -7
View File
@@ -706,14 +706,14 @@ static WebPResult VPXEncode(const uint8* Y,
codec_ctl(&enc, VP8E_SET_STATIC_THRESHOLD, 0);
codec_ctl(&enc, VP8E_SET_TOKEN_PARTITIONS, 2);
vpx_img_wrap(&img, VPX_IMG_FMT_I420,
vpx_img_wrap(&img, IMG_FMT_I420,
y_width, y_height, 16, (uint8*)(Y));
img.planes[VPX_PLANE_Y] = (uint8*)(Y);
img.planes[VPX_PLANE_U] = (uint8*)(U);
img.planes[VPX_PLANE_V] = (uint8*)(V);
img.stride[VPX_PLANE_Y] = y_stride;
img.stride[VPX_PLANE_U] = uv_stride;
img.stride[VPX_PLANE_V] = uv_stride;
img.planes[PLANE_Y] = (uint8*)(Y);
img.planes[PLANE_U] = (uint8*)(U);
img.planes[PLANE_V] = (uint8*)(V);
img.stride[PLANE_Y] = y_stride;
img.stride[PLANE_U] = uv_stride;
img.stride[PLANE_V] = uv_stride;
res = vpx_codec_encode(&enc, &img, 0, 1, 0, VPX_DL_BEST_QUALITY);
-23
View File
@@ -1,23 +0,0 @@
--TEST--
Bug #61221 - imagegammacorrect function loses alpha channel
--SKIPIF--
<?php
if (!extension_loaded('gd')) die('skip gd extension not available');
?>
--FILE--
<?php
$imagew = 50;
$imageh = 50;
$img = imagecreatetruecolor($imagew, $imageh);
$blacktransparent = imagecolorallocatealpha($img, 0, 0, 0, 127);
$redsolid = imagecolorallocate($img, 255, 0, 0);
imagefill($img, 0, 0, $blacktransparent);
imageline($img, $imagew / 2, 0, $imagew / 2, $imageh - 1, $redsolid);
imageline($img, 0, $imageh / 2, $imagew - 1, $imageh / 2, $redsolid);
imagegammacorrect($img, 1, 1);
$color = imagecolorat($img, 0, 0);
var_dump($color === $blacktransparent);
imagedestroy($img);
?>
--EXPECT--
bool(true)
+14 -23
View File
@@ -238,9 +238,6 @@ typedef struct _gmp_temp {
#define GMP_42_OR_NEWER \
((__GNU_MP_VERSION >= 5) || (__GNU_MP_VERSION >= 4 && __GNU_MP_VERSION_MINOR >= 2))
#define GMP_51_OR_NEWER \
((__GNU_MP_VERSION >= 6) || (__GNU_MP_VERSION >= 5 && __GNU_MP_VERSION_MINOR >= 1))
/* The maximum base for input and output conversions is 62 from GMP 4.2
* onwards. */
#if GMP_42_OR_NEWER
@@ -1431,12 +1428,11 @@ ZEND_FUNCTION(gmp_pow)
RETURN_FALSE;
}
INIT_GMP_RETVAL(gmpnum_result);
if (Z_TYPE_P(base_arg) == IS_LONG && Z_LVAL_P(base_arg) >= 0) {
INIT_GMP_RETVAL(gmpnum_result);
mpz_ui_pow_ui(gmpnum_result, Z_LVAL_P(base_arg), exp);
} else {
FETCH_GMP_ZVAL(gmpnum_base, base_arg, temp_base);
INIT_GMP_RETVAL(gmpnum_result);
mpz_pow_ui(gmpnum_result, gmpnum_base, exp);
FREE_GMP_TEMP(temp_base);
}
@@ -1610,14 +1606,13 @@ ZEND_FUNCTION(gmp_rootrem)
add_index_zval(return_value, 0, gmp_create(&gmpnum_result1 TSRMLS_CC));
add_index_zval(return_value, 1, gmp_create(&gmpnum_result2 TSRMLS_CC));
#if GMP_51_OR_NEWER
/* mpz_rootrem() is supported since GMP 4.2, but buggy wrt odd roots
* of negative numbers */
#if GMP_42_OR_NEWER
mpz_rootrem(gmpnum_result1, gmpnum_result2, gmpnum_a, (unsigned long) nth);
#else
mpz_root(gmpnum_result1, gmpnum_a, (unsigned long) nth);
mpz_pow_ui(gmpnum_result2, gmpnum_result1, (unsigned long) nth);
mpz_sub(gmpnum_result2, gmpnum_a, gmpnum_result2);
mpz_abs(gmpnum_result2, gmpnum_result2);
#endif
FREE_GMP_TEMP(temp_a);
@@ -1841,7 +1836,6 @@ ZEND_FUNCTION(gmp_random_range)
{
zval *min_arg, *max_arg;
mpz_ptr gmpnum_min, gmpnum_max, gmpnum_result;
mpz_t gmpnum_range;
gmp_temp_t temp_a, temp_b;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &min_arg, &max_arg) == FAILURE) {
@@ -1860,23 +1854,22 @@ ZEND_FUNCTION(gmp_random_range)
}
INIT_GMP_RETVAL(gmpnum_result);
mpz_init(gmpnum_range);
if (Z_LVAL_P(min_arg) != 0) {
mpz_sub_ui(gmpnum_range, gmpnum_max, Z_LVAL_P(min_arg) - 1);
} else {
mpz_add_ui(gmpnum_range, gmpnum_max, 1);
if (Z_LVAL_P(min_arg)) {
mpz_sub_ui(gmpnum_max, gmpnum_max, Z_LVAL_P(min_arg));
}
mpz_urandomm(gmpnum_result, GMPG(rand_state), gmpnum_range);
mpz_add_ui(gmpnum_max, gmpnum_max, 1);
mpz_urandomm(gmpnum_result, GMPG(rand_state), gmpnum_max);
if (Z_LVAL_P(min_arg) != 0) {
if (Z_LVAL_P(min_arg)) {
mpz_add_ui(gmpnum_result, gmpnum_result, Z_LVAL_P(min_arg));
}
mpz_clear(gmpnum_range);
FREE_GMP_TEMP(temp_a);
} else {
}
else {
FETCH_GMP_ZVAL_DEP(gmpnum_min, min_arg, temp_b, temp_a);
if (mpz_cmp(gmpnum_max, gmpnum_min) <= 0) {
@@ -1887,14 +1880,12 @@ ZEND_FUNCTION(gmp_random_range)
}
INIT_GMP_RETVAL(gmpnum_result);
mpz_init(gmpnum_range);
mpz_sub(gmpnum_range, gmpnum_max, gmpnum_min);
mpz_add_ui(gmpnum_range, gmpnum_range, 1);
mpz_urandomm(gmpnum_result, GMPG(rand_state), gmpnum_range);
mpz_sub(gmpnum_max, gmpnum_max, gmpnum_min);
mpz_add_ui(gmpnum_max, gmpnum_max, 1);
mpz_urandomm(gmpnum_result, GMPG(rand_state), gmpnum_max);
mpz_add(gmpnum_result, gmpnum_result, gmpnum_min);
mpz_clear(gmpnum_range);
FREE_GMP_TEMP(temp_b);
FREE_GMP_TEMP(temp_a);
}
-22
View File
@@ -1,22 +0,0 @@
--TEST--
Bug #69803: gmp_random_range() modifies second parameter if GMP number
--FILE--
<?php
$a = gmp_init(100);
$b = gmp_init(200);
echo $a . ", ", $b . "\n";
gmp_random_range($a, $b);
echo $a . ", ", $b . "\n";
$b = gmp_init(200);
echo $a . ", ", $b . "\n";
gmp_random_range(100, $b);
echo $a . ", ", $b . "\n";
?>
--EXPECT--
100, 200
100, 200
100, 200
100, 200
+2 -2
View File
@@ -13,7 +13,7 @@ var_dump(gmp_random_bits(-1));
gmp_random_bits(1);
gmp_random_bits(1024);
// 0.5 seconds to make sure the numbers stay in range
// 2 seconds to make sure the numbers stay in range
$start = microtime(true);
$limit = (2 ** 30) - 1;
while (1) {
@@ -26,7 +26,7 @@ while (1) {
}
}
if (microtime(true) - $start > 0.5) {
if (microtime(true) - $start > 2) {
break;
}
}
+4 -4
View File
@@ -5,8 +5,8 @@ gmp_random_range() basic tests
--FILE--
<?php
$minusTen = gmp_init(-10);
$plusTen = gmp_init(10);
$minusTen = gmp_init(-1);
$plusTen = gmp_init(1);
$zero = gmp_init(0);
var_dump(gmp_random_range());
@@ -30,7 +30,7 @@ gmp_random_range(-1, $plusTen);
gmp_random_range($zero, $plusTen);
gmp_random_range($minusTen, $plusTen);
// 0.5 seconds to make sure the numbers stay in range
// 2 seconds to make sure the numbers stay in range
$start = microtime(true);
while (1) {
for ($i = 0; $i < 5000; $i++) {
@@ -56,7 +56,7 @@ while (1) {
}
}
if (microtime(true) - $start > 0.5) {
if (microtime(true) - $start > 2) {
break;
}
}
+1 -1
View File
@@ -56,7 +56,7 @@ array(2) {
[1]=>
object(GMP)#%d (1) {
["num"]=>
string(3) "-36"
string(2) "36"
}
}
array(2) {
+4 -35
View File
@@ -35,7 +35,7 @@ if test "$PHP_ICONV" != "no"; then
PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/giconv.h"
else
PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/iconv.h"
fi
fi
AC_MSG_CHECKING([if iconv is glibc's])
AC_TRY_LINK([#include <gnu/libc-version.h>],[gnu_get_libc_version();],
@@ -53,8 +53,8 @@ if test "$PHP_ICONV" != "no"; then
AC_TRY_RUN([
#include <$PHP_ICONV_H_PATH>
int main() {
printf("%d", _libiconv_version);
return 0;
printf("%d", _libiconv_version);
return 0;
}
],[
AC_MSG_RESULT(yes)
@@ -138,7 +138,7 @@ int main() {
if (cd == (iconv_t)(-1)) {
if (errno == EINVAL) {
return 0;
} else {
} else {
return 1;
}
}
@@ -159,37 +159,6 @@ int main() {
AC_DEFINE([ICONV_SUPPORTS_ERRNO],0,[Whether iconv supports error no or not])
])
AC_MSG_CHECKING([if iconv supports //IGNORE])
AC_TRY_RUN([
#include <$PHP_ICONV_H_PATH>
#include <stdlib.h>
int main() {
iconv_t cd = iconv_open( "UTF-8//IGNORE", "UTF-8" );
char *in_p = "\xC3\xC3\xC3\xB8";
size_t in_left = 4, out_left = 4096;
char *out = malloc(out_left);
char *out_p = out;
size_t result = iconv(cd, (char **) &in_p, &in_left, (char **) &out_p, &out_left);
if(result == (size_t)-1) {
return 1;
}
return 0;
}
],[
AC_MSG_RESULT(yes)
PHP_DEFINE([ICONV_BROKEN_IGNORE],0,[ext/iconv])
AC_DEFINE([ICONV_BROKEN_IGNORE],0,[Whether iconv supports IGNORE])
],[
AC_MSG_RESULT(no)
PHP_DEFINE([ICONV_BROKEN_IGNORE],1,[ext/iconv])
AC_DEFINE([ICONV_BROKEN_IGNORE],1,[Whether iconv supports IGNORE])
],[
AC_MSG_RESULT(no, cross-compiling)
PHP_DEFINE([ICONV_BROKEN_IGNORE],0,[ext/iconv])
AC_DEFINE([ICONV_BROKEN_IGNORE],0,[Whether iconv supports IGNORE])
])
AC_MSG_CHECKING([if your cpp allows macro usage in include lines])
AC_TRY_COMPILE([
#define FOO <$PHP_ICONV_H_PATH>
-30
View File
@@ -529,24 +529,6 @@ static php_iconv_err_t _php_iconv_appendc(smart_str *d, const char c, iconv_t cd
}
/* }}} */
/* {{{ */
#if ICONV_BROKEN_IGNORE
static int _php_check_ignore(const char *charset)
{
size_t clen = strlen(charset);
if (clen >= 9 && strcmp("//IGNORE", charset+clen-8) == 0) {
return 1;
}
if (clen >= 19 && strcmp("//IGNORE//TRANSLIT", charset+clen-18) == 0) {
return 1;
}
return 0;
}
#else
#define _php_check_ignore(x) (0)
#endif
/* }}} */
/* {{{ php_iconv_string()
*/
PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
@@ -628,7 +610,6 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
char *out_p, *out_buf, *tmp_buf;
size_t bsz, result = 0;
php_iconv_err_t retval = PHP_ICONV_ERR_SUCCESS;
int ignore_ilseq = _php_check_ignore(out_charset);
*out = NULL;
*out_len = 0;
@@ -653,17 +634,6 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
result = iconv(cd, (char **) &in_p, &in_left, (char **) &out_p, &out_left);
out_size = bsz - out_left;
if (result == (size_t)(-1)) {
if (ignore_ilseq && errno == EILSEQ) {
if (in_left <= 1) {
result = 0;
} else {
errno = 0;
in_p++;
in_left--;
continue;
}
}
if (errno == E2BIG && in_left > 0) {
/* converted string is longer than out buffer */
bsz += in_len;
-27
View File
@@ -1,27 +0,0 @@
--TEST--
Bug #48147 (iconv with //IGNORE cuts the string)
--SKIPIF--
<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
--FILE--
<?php
$text = "aa\xC3\xC3\xC3\xB8aa";
var_dump(iconv("UTF-8", "UTF-8", $text));
var_dump(urlencode(iconv("UTF-8", "UTF-8//IGNORE", $text)));
// only invalid
var_dump(urlencode(iconv("UTF-8", "UTF-8//IGNORE", "\xC3")));
// start invalid
var_dump(urlencode(iconv("UTF-8", "UTF-8//IGNORE", "\xC3\xC3\xC3\xB8aa")));
// finish invalid
var_dump(urlencode(iconv("UTF-8", "UTF-8//IGNORE", "aa\xC3\xC3\xC3")));
?>
--EXPECTF--
Notice: iconv(): Detected an illegal character in input string in %s on line %d
bool(false)
string(10) "aa%C3%B8aa"
Notice: iconv(): Detected an incomplete multibyte character in input string in %s on line %d
string(0) ""
string(8) "%C3%B8aa"
Notice: iconv(): Detected an incomplete multibyte character in input string in %s on line %d
string(0) ""
+1 -1
View File
@@ -9,7 +9,7 @@ if test "$PHP_JSON" != "no"; then
AC_DEFINE([HAVE_JSON],1 ,[whether to enable JavaScript Object Serialization support])
AC_HEADER_STDC
PHP_NEW_EXTENSION(json, json.c JSON_parser.c, $ext_shared)
PHP_NEW_EXTENSION(json, json.c utf8_decode.c JSON_parser.c, $ext_shared)
PHP_INSTALL_HEADERS([ext/json], [php_json.h])
PHP_SUBST(JSON_SHARED_LIBADD)
fi
+1 -1
View File
@@ -5,7 +5,7 @@ ARG_ENABLE("json", "JavaScript Object Serialization support", "yes");
if (PHP_JSON != "no") {
EXTENSION('json', 'json.c', PHP_JSON_SHARED, "");
ADD_SOURCES(configure_module_dirname, "JSON_parser.c", "json");
ADD_SOURCES(configure_module_dirname, "JSON_parser.c utf8_decode.c", "json");
PHP_INSTALL_HEADERS("ext/json/", "php_json.h");
}
+16
View File
@@ -102,6 +102,22 @@ SOURCE=.\JSON_parser.c
SOURCE=.\JSON_parser.h
# End Source File
# Begin Source File
SOURCE=.\utf8_decode.c
# End Source File
# Begin Source File
SOURCE=.\utf8_decode.h
# End Source File
# Begin Source File
SOURCE=.\utf8_to_utf16.c
# End Source File
# Begin Source File
SOURCE=.\utf8_to_utf16.h
# End Source File
# End Group
# Begin Group "Header Files"
+4
View File
@@ -36,6 +36,10 @@
<file role="src" name="JSON_parser.c" />
<file role="src" name="JSON_parser.h" />
<file role="src" name="php_json.h" />
<file role="src" name="utf8_decode.c" />
<file role="src" name="utf8_decode.h" />
<file role="src" name="utf8_to_utf16.c" />
<file role="src" name="utf8_to_utf16.h" />
<dir role="test" name="tests">
<file role="test" name="fail001.phpt" />
<file role="test" name="pass001.phpt" />
+179
View File
@@ -0,0 +1,179 @@
/* utf8_decode.c */
/* 2005-12-25 */
/*
Copyright (c) 2005 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "utf8_decode.h"
/*
Very Strict UTF-8 Decoder
UTF-8 is a multibyte character encoding of Unicode. A character can be
represented by 1-4 bytes. The bit pattern of the first byte indicates the
number of continuation bytes.
Most UTF-8 decoders tend to be lenient, attempting to recover as much
information as possible, even from badly encoded input. This UTF-8
decoder is not lenient. It will reject input which does not include
proper continuation bytes. It will reject aliases (or suboptimal
codings). It will reject surrogates. (Surrogate encoding should only be
used with UTF-16.)
Code Contination Minimum Maximum
0xxxxxxx 0 0 127
10xxxxxx error
110xxxxx 1 128 2047
1110xxxx 2 2048 65535 excluding 55296 - 57343
11110xxx 3 65536 1114111
11111xxx error
*/
/*
Get the next byte. It returns UTF8_END if there are no more bytes.
*/
static int
get(json_utf8_decode *utf8)
{
int c;
if (utf8->the_index >= utf8->the_length) {
return UTF8_END;
}
c = utf8->the_input[utf8->the_index] & 0xFF;
utf8->the_index += 1;
return c;
}
/*
Get the 6-bit payload of the next continuation byte.
Return UTF8_ERROR if it is not a contination byte.
*/
static int
cont(json_utf8_decode *utf8)
{
int c = get(utf8);
return ((c & 0xC0) == 0x80) ? (c & 0x3F) : UTF8_ERROR;
}
/*
Initialize the UTF-8 decoder. The decoder is not reentrant,
*/
void
utf8_decode_init(json_utf8_decode *utf8, char p[], int length)
{
utf8->the_index = 0;
utf8->the_input = p;
utf8->the_length = length;
utf8->the_char = 0;
utf8->the_byte = 0;
}
/*
Get the current byte offset. This is generally used in error reporting.
*/
int
utf8_decode_at_byte(json_utf8_decode *utf8)
{
return utf8->the_byte;
}
/*
Get the current character offset. This is generally used in error reporting.
The character offset matches the byte offset if the text is strictly ASCII.
*/
int
utf8_decode_at_character(json_utf8_decode *utf8)
{
return utf8->the_char > 0 ? utf8->the_char - 1 : 0;
}
/*
Extract the next character.
Returns: the character (between 0 and 1114111)
or UTF8_END (the end)
or UTF8_ERROR (error)
*/
int
utf8_decode_next(json_utf8_decode *utf8)
{
int c; /* the first byte of the character */
int r; /* the result */
if (utf8->the_index >= utf8->the_length) {
return utf8->the_index == utf8->the_length ? UTF8_END : UTF8_ERROR;
}
utf8->the_byte = utf8->the_index;
utf8->the_char += 1;
c = get(utf8);
/*
Zero continuation (0 to 127)
*/
if ((c & 0x80) == 0) {
return c;
}
/*
One contination (128 to 2047)
*/
if ((c & 0xE0) == 0xC0) {
int c1 = cont(utf8);
if (c1 < 0) {
return UTF8_ERROR;
}
r = ((c & 0x1F) << 6) | c1;
return r >= 128 ? r : UTF8_ERROR;
}
/*
Two continuation (2048 to 55295 and 57344 to 65535)
*/
if ((c & 0xF0) == 0xE0) {
int c1 = cont(utf8);
int c2 = cont(utf8);
if (c1 < 0 || c2 < 0) {
return UTF8_ERROR;
}
r = ((c & 0x0F) << 12) | (c1 << 6) | c2;
return r >= 2048 && (r < 55296 || r > 57343) ? r : UTF8_ERROR;
}
/*
Three continuation (65536 to 1114111)
*/
if ((c & 0xF8) == 0xF0) {
int c1 = cont(utf8);
int c2 = cont(utf8);
int c3 = cont(utf8);
if (c1 < 0 || c2 < 0 || c3 < 0) {
return UTF8_ERROR;
}
r = ((c & 0x0F) << 18) | (c1 << 12) | (c2 << 6) | c3;
return r >= 65536 && r <= 1114111 ? r : UTF8_ERROR;
}
return UTF8_ERROR;
}
+18
View File
@@ -0,0 +1,18 @@
/* utf8_decode.h */
#define UTF8_END -1
#define UTF8_ERROR -2
typedef struct json_utf8_decode
{
int the_index;
char *the_input;
int the_length;
int the_char;
int the_byte;
} json_utf8_decode;
extern int utf8_decode_at_byte(json_utf8_decode *utf8);
extern int utf8_decode_at_character(json_utf8_decode *utf8);
extern void utf8_decode_init(json_utf8_decode *utf8, char p[], int length);
extern int utf8_decode_next(json_utf8_decode *utf8);
+84 -137
View File
@@ -22,7 +22,7 @@
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#define IS_EXT_MODULE
@@ -96,21 +96,13 @@ static void _close_ldap_link(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
{
ldap_linkdata *ld = (ldap_linkdata *)rsrc->ptr;
/* ldap_unbind_s() is deprecated;
* the distinction between ldap_unbind() and ldap_unbind_s() is moot */
#ifdef LDAP_API_FEATURE_X_OPENLDAP
ldap_unbind_ext(ld->link, NULL, NULL);
#ifdef HAVE_3ARG_SETREBINDPROC
ldap_unbind_s(ld->link);
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
if (ld->rebindproc != NULL) {
zval_dtor(ld->rebindproc);
FREE_ZVAL(ld->rebindproc);
}
#endif
#else /* ! LDAP_API_FEATURE_X_OPENLDAP */
ldap_unbind_s(ld->link);
#endif /* ! LDAP_API_FEATURE_X_OPENLDAP */
efree(ld);
LDAPG(num_links)--;
}
@@ -133,7 +125,7 @@ static void _free_ldap_result_entry(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{
}
zend_list_delete(entry->id);
efree(entry);
}
}
/* }}} */
/* {{{ PHP_INI_BEGIN
@@ -202,10 +194,6 @@ PHP_MINIT_FUNCTION(ldap)
REGISTER_LONG_CONSTANT("LDAP_OPT_DEBUG_LEVEL", LDAP_OPT_DEBUG_LEVEL, CONST_PERSISTENT | CONST_CS);
#endif
#ifdef LDAP_OPT_DIAGNOSTIC_MESSAGE
REGISTER_LONG_CONSTANT("LDAP_OPT_DIAGNOSTIC_MESSAGE", LDAP_OPT_DIAGNOSTIC_MESSAGE, CONST_PERSISTENT | CONST_CS);
#endif
#ifdef HAVE_LDAP_SASL
REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_MECH", LDAP_OPT_X_SASL_MECH, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_OPT_X_SASL_REALM", LDAP_OPT_X_SASL_REALM, CONST_PERSISTENT | CONST_CS);
@@ -310,13 +298,7 @@ PHP_FUNCTION(ldap_connect)
{
char *host = NULL;
int hostlen;
long port =
#ifdef LDAP_API_FEATURE_X_OPENLDAP
LDAP_PORT
#else /* ! LDAP_API_FEATURE_X_OPENLDAP */
389 /* Default port */
#endif /* ! LDAP_API_FEATURE_X_OPENLDAP */
;
long port = 389; /* Default port */
#ifdef HAVE_ORALDAP
char *wallet = NULL, *walletpasswd = NULL;
int walletlen = 0, walletpasswdlen = 0;
@@ -324,7 +306,7 @@ PHP_FUNCTION(ldap_connect)
int ssl=0;
#endif
ldap_linkdata *ld;
LDAP *ldap = NULL;
LDAP *ldap;
#ifdef HAVE_ORALDAP
if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) {
@@ -352,38 +334,22 @@ PHP_FUNCTION(ldap_connect)
ld = ecalloc(1, sizeof(ldap_linkdata));
#ifdef LDAP_API_FEATURE_X_OPENLDAP
/* OpenLDAP provides a specific call to detect valid LDAP URIs;
* ldap_init()/ldap_open() is deprecated, use ldap_initialize() instead.
*/
{
if (host != NULL && strchr(host, '/')) {
int rc;
char *url = host;
if (!ldap_is_ldap_url(url)) {
int urllen = hostlen + sizeof( "ldap://:65535" );
if (port <= 0 || port > 65535) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid port number: %ld", port);
RETURN_FALSE;
}
url = emalloc(urllen);
snprintf( url, urllen, "ldap://%s:%ld", host ? host : "", port );
}
rc = ldap_initialize(&ldap, url);
if (url != host) {
efree(url);
}
rc = ldap_initialize(&ldap, host);
if (rc != LDAP_SUCCESS) {
efree(ld);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create session handle: %s", ldap_err2string(rc));
RETURN_FALSE;
}
} else {
ldap = ldap_init(host, port);
}
#else /* ! LDAP_API_FEATURE_X_OPENLDAP */
#else
ldap = ldap_open(host, port);
#endif /* ! LDAP_API_FEATURE_X_OPENLDAP */
#endif
if (ldap == NULL) {
efree(ld);
RETURN_FALSE;
@@ -395,7 +361,7 @@ PHP_FUNCTION(ldap_connect)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL init failed");
RETURN_FALSE;
}
}
}
#endif
LDAPG(num_links)++;
ld->link = ldap;
@@ -470,21 +436,7 @@ PHP_FUNCTION(ldap_bind)
RETURN_FALSE;
}
#ifdef LDAP_API_FEATURE_X_OPENLDAP
{
struct berval cred;
/* ldap_bind_s() is deprecated; use ldap_sasl_bind_s() instead */
cred.bv_val = ldap_bind_pw;
cred.bv_len = ldap_bind_pw ? ldap_bind_pwlen : 0;
rc = ldap_sasl_bind_s(ld->link, ldap_bind_dn, LDAP_SASL_SIMPLE, &cred,
NULL, NULL, /* no controls right now */
NULL); /* we don't care about the server's credentials */
}
#else
rc = ldap_bind_s(ld->link, ldap_bind_dn, ldap_bind_pw, LDAP_AUTH_SIMPLE);
#endif
if ( rc != LDAP_SUCCESS) {
if ((rc = ldap_bind_s(ld->link, ldap_bind_dn, ldap_bind_pw, LDAP_AUTH_SIMPLE)) != LDAP_SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to bind to server: %s", ldap_err2string(rc));
RETURN_FALSE;
} else {
@@ -508,7 +460,7 @@ static php_ldap_bictx *_php_sasl_setdefs(LDAP *ld, char *sasl_mech, char *sasl_r
{
php_ldap_bictx *ctx;
ctx = ber_memalloc(sizeof(php_ldap_bictx));
ctx = ber_memalloc(sizeof(php_ldap_bictx));
ctx->mech = (sasl_mech) ? ber_strdup(sasl_mech) : NULL;
ctx->realm = (sasl_realm) ? ber_strdup(sasl_realm) : NULL;
ctx->authcid = (sasl_authc_id) ? ber_strdup(sasl_authc_id) : NULL;
@@ -646,8 +598,8 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref, in
ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_sizelimit);
ldap_set_option(ldap, LDAP_OPT_SIZELIMIT, &sizelimit);
#else
*old_sizelimit = ldap->ld_sizelimit;
ldap->ld_sizelimit = sizelimit;
*old_sizelimit = ldap->ld_sizelimit;
ldap->ld_sizelimit = sizelimit;
#endif
}
@@ -657,8 +609,8 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref, in
ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_timelimit);
ldap_set_option(ldap, LDAP_OPT_TIMELIMIT, &timelimit);
#else
*old_timelimit = ldap->ld_timelimit;
ldap->ld_timelimit = timelimit;
*old_timelimit = ldap->ld_timelimit;
ldap->ld_timelimit = timelimit;
#endif
}
@@ -668,8 +620,8 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref, in
ldap_get_option(ldap, LDAP_OPT_SIZELIMIT, old_deref);
ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
#else
*old_deref = ldap->ld_deref;
ldap->ld_deref = deref;
*old_deref = ldap->ld_deref;
ldap->ld_deref = deref;
#endif
}
}
@@ -681,11 +633,11 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
{
zval *link, *base_dn, **filter, *attrs = NULL, **attr;
long attrsonly, sizelimit, timelimit, deref;
char *ldap_base_dn = NULL, *ldap_filter = NULL, **ldap_attrs = NULL;
char *ldap_base_dn = NULL, *ldap_filter = NULL, **ldap_attrs = NULL;
ldap_linkdata *ld = NULL;
LDAPMessage *ldap_res;
int ldap_attrsonly = 0, ldap_sizelimit = -1, ldap_timelimit = -1, ldap_deref = -1;
int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1;
int ldap_attrsonly = 0, ldap_sizelimit = -1, ldap_timelimit = -1, ldap_deref = -1;
int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1;
int num_attribs = 0, ret = 1, i, errno, argcount = ZEND_NUM_ARGS();
if (zend_parse_parameters(argcount TSRMLS_CC, "zzZ|allll", &link, &base_dn, &filter, &attrs, &attrsonly,
@@ -728,7 +680,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
int i, nlinks, nbases, nfilters, *rcs;
ldap_linkdata **lds;
zval **entry, *resource;
nlinks = zend_hash_num_elements(Z_ARRVAL_P(link));
if (nlinks == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No links in link array");
@@ -770,7 +722,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
lds = safe_emalloc(nlinks, sizeof(ldap_linkdata), 0);
rcs = safe_emalloc(nlinks, sizeof(*rcs), 0);
zend_hash_internal_pointer_reset(Z_ARRVAL_P(link));
for (i=0; i<nlinks; i++) {
zend_hash_get_current_data(Z_ARRVAL_P(link), (void **)&entry);
@@ -800,12 +752,12 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref);
/* Run the actual search */
/* Run the actual search */
rcs[i] = ldap_search(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly);
lds[i] = ld;
zend_hash_move_forward(Z_ARRVAL_P(link));
}
array_init(return_value);
/* Collect results from the searches */
@@ -842,9 +794,9 @@ cleanup_parallel:
php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref);
/* Run the actual search */
/* Run the actual search */
errno = ldap_search_s(ld->link, ldap_base_dn, scope, ldap_filter, ldap_attrs, ldap_attrsonly, &ldap_res);
if (errno != LDAP_SUCCESS
&& errno != LDAP_SIZELIMIT_EXCEEDED
#ifdef LDAP_ADMINLIMIT_EXCEEDED
@@ -865,7 +817,7 @@ cleanup_parallel:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Partial search results returned: Adminlimit exceeded");
}
#endif
ZEND_REGISTER_RESOURCE(return_value, ldap_res, le_result);
}
}
@@ -950,7 +902,7 @@ PHP_FUNCTION(ldap_count_entries)
PHP_FUNCTION(ldap_first_entry)
{
zval *link, *result;
ldap_linkdata *ld;
ldap_linkdata *ld;
ldap_resultentry *resultentry;
LDAPMessage *ldap_result, *entry;
@@ -1035,7 +987,7 @@ PHP_FUNCTION(ldap_get_entries)
if (num_entries == 0) {
return;
}
ldap_result_entry = ldap_first_entry(ldap, ldap_result);
if (ldap_result_entry == NULL) {
zval_dtor(return_value);
@@ -1059,7 +1011,7 @@ PHP_FUNCTION(ldap_get_entries)
add_assoc_long(tmp2, "count", num_values);
for (i = 0; i < num_values; i++) {
add_index_stringl(tmp2, i, ldap_value[i]->bv_val, ldap_value[i]->bv_len, 1);
}
}
ldap_value_free_len(ldap_value);
attr_len = strlen(attribute);
@@ -1088,7 +1040,7 @@ PHP_FUNCTION(ldap_get_entries)
#endif
zend_hash_index_update(Z_ARRVAL_P(return_value), num_entries, (void *) &tmp1, sizeof(zval *), NULL);
num_entries++;
ldap_result_entry = ldap_next_entry(ldap, ldap_result_entry);
}
@@ -1187,7 +1139,7 @@ PHP_FUNCTION(ldap_get_attributes)
array_init(return_value);
num_attrib = 0;
attribute = ldap_first_attribute(ld->link, resultentry->data, &ber);
while (attribute != NULL) {
ldap_value = ldap_get_values_len(ld->link, resultentry->data, attribute);
@@ -1215,7 +1167,7 @@ PHP_FUNCTION(ldap_get_attributes)
ber_free(ber, 0);
}
#endif
add_assoc_long(return_value, "count", num_attrib);
}
/* }}} */
@@ -1230,11 +1182,11 @@ PHP_FUNCTION(ldap_get_values_len)
char *attr;
struct berval **ldap_value_len;
int i, num_values, attr_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrs", &link, &result_entry, &attr, &attr_len) != SUCCESS) {
return;
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, &result_entry, -1, "ldap result entry", le_result_entry);
@@ -1242,14 +1194,14 @@ PHP_FUNCTION(ldap_get_values_len)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot get the value(s) of attribute %s", ldap_err2string(_get_lderrno(ld->link)));
RETURN_FALSE;
}
num_values = ldap_count_values_len(ldap_value_len);
array_init(return_value);
for (i=0; i<num_values; i++) {
add_next_index_stringl(return_value, ldap_value_len[i]->bv_val, ldap_value_len[i]->bv_len, 1);
}
add_assoc_long(return_value, "count", num_values);
ldap_value_free_len(ldap_value_len);
@@ -1258,7 +1210,7 @@ PHP_FUNCTION(ldap_get_values_len)
/* {{{ proto string ldap_get_dn(resource link, resource result_entry)
Get the DN of a result entry */
PHP_FUNCTION(ldap_get_dn)
PHP_FUNCTION(ldap_get_dn)
{
zval *link, *result_entry;
ldap_linkdata *ld;
@@ -1268,7 +1220,7 @@ PHP_FUNCTION(ldap_get_dn)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &link, &result_entry) != SUCCESS) {
return;
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, &result_entry, -1, "ldap result entry", le_result_entry);
@@ -1314,12 +1266,7 @@ PHP_FUNCTION(ldap_explode_dn)
add_index_string(return_value, i, ldap_value[i], 1);
}
#ifdef LDAP_API_FEATURE_X_OPENLDAP
/* ldap_value_free() is deprecated */
ber_memvfree((void **)ldap_value);
#else /* ! LDAP_API_FEATURE_X_OPENLDAP */
ldap_value_free(ldap_value);
#endif /* ! LDAP_API_FEATURE_X_OPENLDAP */
}
/* }}} */
@@ -1333,9 +1280,9 @@ PHP_FUNCTION(ldap_dn2ufn)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &dn, &dn_len) != SUCCESS) {
return;
}
ufn = ldap_dn2ufn(dn);
if (ufn != NULL) {
RETVAL_STRING(ufn, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP || WINDOWS
@@ -1366,7 +1313,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsa", &link, &dn, &dn_len, &entry) != SUCCESS) {
return;
}
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
@@ -1400,7 +1347,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
i--;
}
efree(num_berval);
efree(ldap_mods);
efree(ldap_mods);
RETURN_FALSE;
}
@@ -1411,7 +1358,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
} else {
num_values = zend_hash_num_elements(Z_ARRVAL_PP(value));
}
num_berval[i] = num_values;
ldap_mods[i]->mod_bvalues = safe_emalloc((num_values + 1), sizeof(struct berval *), 0);
@@ -1421,7 +1368,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
ldap_mods[i]->mod_bvalues[0] = (struct berval *) emalloc (sizeof(struct berval));
ldap_mods[i]->mod_bvalues[0]->bv_len = Z_STRLEN_PP(value);
ldap_mods[i]->mod_bvalues[0]->bv_val = Z_STRVAL_PP(value);
} else {
} else {
for (j = 0; j < num_values; j++) {
if (zend_hash_index_find(Z_ARRVAL_PP(value), j, (void **) &ivalue) != SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Value array must have consecutive indices 0, 1, ...");
@@ -1451,7 +1398,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
if ((i = ldap_modify_ext_s(ld->link, dn, ldap_mods, NULL, NULL)) != LDAP_SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Modify: %s", ldap_err2string(i));
RETVAL_FALSE;
} else RETVAL_TRUE;
} else RETVAL_TRUE;
}
errexit:
@@ -1464,7 +1411,7 @@ errexit:
efree(ldap_mods[i]);
}
efree(num_berval);
efree(ldap_mods);
efree(ldap_mods);
return;
}
@@ -1911,7 +1858,7 @@ PHP_FUNCTION(ldap_err2str)
/* {{{ proto string ldap_error(resource link)
Get the current ldap error string */
PHP_FUNCTION(ldap_error)
PHP_FUNCTION(ldap_error)
{
zval *link;
ldap_linkdata *ld;
@@ -1931,7 +1878,7 @@ PHP_FUNCTION(ldap_error)
/* {{{ proto bool ldap_compare(resource link, string dn, string attr, string value)
Determine if an entry has a specific value for one of its attributes */
PHP_FUNCTION(ldap_compare)
PHP_FUNCTION(ldap_compare)
{
zval *link;
char *dn, *attr, *value;
@@ -1956,7 +1903,7 @@ PHP_FUNCTION(ldap_compare)
RETURN_FALSE;
break;
}
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Compare: %s", ldap_err2string(errno));
RETURN_LONG(-1);
}
@@ -1995,12 +1942,12 @@ PHP_FUNCTION(ldap_sort)
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP
/* {{{ proto bool ldap_get_option(resource link, int option, mixed retval)
Get the current value of various session-wide parameters */
PHP_FUNCTION(ldap_get_option)
PHP_FUNCTION(ldap_get_option)
{
zval *link, *retval;
ldap_linkdata *ld;
long option;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &link, &option, &retval) != SUCCESS) {
return;
}
@@ -2037,7 +1984,7 @@ PHP_FUNCTION(ldap_get_option)
ldap_memfree(timeout);
}
RETURN_FALSE;
}
}
if (!timeout) {
RETURN_FALSE;
}
@@ -2052,7 +1999,7 @@ PHP_FUNCTION(ldap_get_option)
if (ldap_get_option(ld->link, LDAP_X_OPT_CONNECT_TIMEOUT, &timeout)) {
RETURN_FALSE;
}
}
zval_dtor(retval);
ZVAL_LONG(retval, (timeout / 1000));
} break;
@@ -2063,7 +2010,7 @@ PHP_FUNCTION(ldap_get_option)
case LDAP_OPT_HOST_NAME:
#endif
#ifdef HAVE_LDAP_SASL
case LDAP_OPT_X_SASL_MECH:
case LDAP_OPT_X_SASL_MECH:
case LDAP_OPT_X_SASL_REALM:
case LDAP_OPT_X_SASL_AUTHCID:
case LDAP_OPT_X_SASL_AUTHZID:
@@ -2099,13 +2046,13 @@ PHP_FUNCTION(ldap_get_option)
/* {{{ proto bool ldap_set_option(resource link, int option, mixed newval)
Set the value of various session-wide parameters */
PHP_FUNCTION(ldap_set_option)
PHP_FUNCTION(ldap_set_option)
{
zval *link, **newval;
ldap_linkdata *ld;
LDAP *ldap;
long option;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zlZ", &link, &option, &newval) != SUCCESS) {
return;
}
@@ -2146,7 +2093,7 @@ PHP_FUNCTION(ldap_set_option)
timeout.tv_usec = 0;
if (ldap_set_option(ldap, LDAP_OPT_NETWORK_TIMEOUT, (void *) &timeout)) {
RETURN_FALSE;
}
}
} break;
#elif defined(LDAP_X_OPT_CONNECT_TIMEOUT)
case LDAP_X_OPT_CONNECT_TIMEOUT:
@@ -2157,7 +2104,7 @@ PHP_FUNCTION(ldap_set_option)
timeout = 1000 * Z_LVAL_PP(newval); /* Convert to milliseconds */
if (ldap_set_option(ldap, LDAP_X_OPT_CONNECT_TIMEOUT, &timeout)) {
RETURN_FALSE;
}
}
} break;
#endif
/* options with string value */
@@ -2166,7 +2113,7 @@ PHP_FUNCTION(ldap_set_option)
case LDAP_OPT_HOST_NAME:
#endif
#ifdef HAVE_LDAP_SASL
case LDAP_OPT_X_SASL_MECH:
case LDAP_OPT_X_SASL_MECH:
case LDAP_OPT_X_SASL_REALM:
case LDAP_OPT_X_SASL_AUTHCID:
case LDAP_OPT_X_SASL_AUTHZID:
@@ -2241,7 +2188,7 @@ PHP_FUNCTION(ldap_set_option)
} else {
ctrl->ldctl_iscritical = 0;
}
++ctrlp;
*ctrlp = NULL;
zend_hash_move_forward(Z_ARRVAL_PP(newval));
@@ -2269,7 +2216,7 @@ PHP_FUNCTION(ldap_set_option)
#ifdef HAVE_LDAP_PARSE_RESULT
/* {{{ proto bool ldap_parse_result(resource link, resource result, int errcode, string matcheddn, string errmsg, array referrals)
Extract information from result */
PHP_FUNCTION(ldap_parse_result)
PHP_FUNCTION(ldap_parse_result)
{
zval *link, *result, *errcode, *matcheddn, *errmsg, *referrals;
ldap_linkdata *ld;
@@ -2279,7 +2226,7 @@ PHP_FUNCTION(ldap_parse_result)
int rc, lerrcode, myargcount = ZEND_NUM_ARGS();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrz|zzz", &link, &result, &errcode, &matcheddn, &errmsg, &referrals) != SUCCESS) {
return;
return;
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
@@ -2320,7 +2267,7 @@ PHP_FUNCTION(ldap_parse_result)
ZVAL_STRING(errmsg, lerrmsg, 1);
ldap_memfree(lerrmsg);
}
case 4:
case 4:
zval_dtor(matcheddn);
if (lmatcheddn == NULL) {
ZVAL_EMPTY_STRING(matcheddn);
@@ -2438,7 +2385,7 @@ PHP_FUNCTION(ldap_rename)
char *dn, *newrdn, *newparent;
int dn_len, newrdn_len, newparent_len;
zend_bool deleteoldrdn;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsssb", &link, &dn, &dn_len, &newrdn, &newrdn_len, &newparent, &newparent_len, &deleteoldrdn) != SUCCESS) {
return;
}
@@ -2663,11 +2610,11 @@ PHP_FUNCTION(ldap_escape)
#ifdef STR_TRANSLATION
/* {{{ php_ldap_do_translate
*/
static void php_ldap_do_translate(INTERNAL_FUNCTION_PARAMETERS, int way)
static void php_ldap_do_translate(INTERNAL_FUNCTION_PARAMETERS, int way)
{
char *value;
int result, ldap_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) != SUCCESS) {
return;
}
@@ -2712,7 +2659,7 @@ PHP_FUNCTION(ldap_8859_to_t61)
#ifdef LDAP_CONTROL_PAGEDRESULTS
/* {{{ proto mixed ldap_control_paged_result(resource link, int pagesize [, bool iscritical [, string cookie]])
Inject paged results control*/
PHP_FUNCTION(ldap_control_paged_result)
PHP_FUNCTION(ldap_control_paged_result)
{
long pagesize;
zend_bool iscritical;
@@ -2804,7 +2751,7 @@ lcpr_error_out:
/* {{{ proto bool ldap_control_paged_result_response(resource link, resource result [, string &cookie [, int &estimated]])
Extract paged results control response */
PHP_FUNCTION(ldap_control_paged_result_response)
PHP_FUNCTION(ldap_control_paged_result_response)
{
zval *link, *result, *cookie, *estimated;
struct berval lcookie;
@@ -3171,9 +3118,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_8859_to_t61, 0, 0, 1)
ZEND_END_ARG_INFO()
#endif
/* }}} */
/*
This is just a small subset of the functionality provided by the LDAP library. All the
This is just a small subset of the functionality provided by the LDAP library. All the
operations are synchronous. Referrals are not handled automatically.
*/
/* {{{ ldap_functions[]
@@ -3257,13 +3204,13 @@ const zend_function_entry ldap_functions[] = {
zend_module_entry ldap_module_entry = { /* {{{ */
STANDARD_MODULE_HEADER,
"ldap",
ldap_functions,
PHP_MINIT(ldap),
PHP_MSHUTDOWN(ldap),
"ldap",
ldap_functions,
PHP_MINIT(ldap),
PHP_MSHUTDOWN(ldap),
NULL,
NULL,
NULL,
PHP_MINFO(ldap),
PHP_MINFO(ldap),
NO_VERSION_YET,
PHP_MODULE_GLOBALS(ldap),
PHP_GINIT(ldap),
+10 -10
View File
@@ -12,9 +12,9 @@ require_once('skipifbindfailure.inc');
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
insert_dummy_data($link);
$dn = "$base";
$dn = "dc=my-domain,dc=com";
$filter = "(objectclass=person)";
var_dump(
@@ -36,7 +36,7 @@ var_dump(
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECTF--
resource(%d) of type (ldap result)
@@ -57,7 +57,7 @@ array(4) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userA,%s"
string(28) "cn=userA,dc=my-domain,dc=com"
}
[1]=>
array(4) {
@@ -73,7 +73,7 @@ array(4) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userB,%s"
string(28) "cn=userB,dc=my-domain,dc=com"
}
[2]=>
array(4) {
@@ -89,7 +89,7 @@ array(4) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userC,cn=userB,%s"
string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
}
}
@@ -110,7 +110,7 @@ array(2) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userA,%s"
string(28) "cn=userA,dc=my-domain,dc=com"
}
}
resource(%d) of type (ldap result)
@@ -131,7 +131,7 @@ array(4) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userA,%s"
string(28) "cn=userA,dc=my-domain,dc=com"
}
[1]=>
array(4) {
@@ -147,7 +147,7 @@ array(4) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userB,%s"
string(28) "cn=userB,dc=my-domain,dc=com"
}
[2]=>
array(4) {
@@ -163,7 +163,7 @@ array(4) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userC,cn=userB,%s"
string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
}
}
===DONE===
+17 -16
View File
@@ -1,14 +1,13 @@
<?php
/*
Default values are "localhost", "cn=Manager,dc=my-domain,dc=com", and password "secret".
Default values are "localhost", "root", database "test" and empty password.
Change the LDAP_TEST_* environment values if you want to use another configuration.
*/
$host = getenv("LDAP_TEST_HOST") ? getenv("LDAP_TEST_HOST") : "localhost";
$port = getenv("LDAP_TEST_PORT") ? getenv("LDAP_TEST_PORT") : 389;
$base = getenv("LDAP_TEST_BASE") ? getenv("LDAP_TEST_BASE") : "dc=my-domain,dc=com";
$user = getenv("LDAP_TEST_USER") ? getenv("LDAP_TEST_USER") : "cn=Manager,$base";
$user = getenv("LDAP_TEST_USER") ? getenv("LDAP_TEST_USER") : "cn=Manager,dc=my-domain,dc=com";
$sasl_user = getenv("LDAP_TEST_SASL_USER") ? getenv("LDAP_TEST_SASL_USER") : "Manager";
$passwd = getenv("LDAP_TEST_PASSWD") ? getenv("LDAP_TEST_PASSWD") : "secret";
$protocol_version = getenv("LDAP_TEST_OPT_PROTOCOL_VERSION") ? getenv("LDAP_TEST_OPT_PROTOCOL_VERSION") : 3;
@@ -21,14 +20,16 @@ function ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version)
return $link;
}
function insert_dummy_data($link, $base) {
ldap_add($link, "o=test,$base", array(
function insert_dummy_data($link) {
ldap_add($link, "dc=my-domain,dc=com", array(
"objectClass" => array(
"top",
"organization"),
"o" => "test",
"top",
"dcObject",
"organization"),
"dc" => "my-domain",
"o" => "my-domain",
));
ldap_add($link, "cn=userA,$base", array(
ldap_add($link, "cn=userA,dc=my-domain,dc=com", array(
"objectclass" => "person",
"cn" => "userA",
"sn" => "testSN1",
@@ -36,14 +37,14 @@ function insert_dummy_data($link, $base) {
"telephoneNumber" => "xx-xx-xx-xx-xx",
"description" => "user A",
));
ldap_add($link, "cn=userB,$base", array(
ldap_add($link, "cn=userB,dc=my-domain,dc=com", array(
"objectclass" => "person",
"cn" => "userB",
"sn" => "testSN2",
"userPassword" => "oopsIDitItAgain",
"description" => "user B",
));
ldap_add($link, "cn=userC,cn=userB,$base", array(
ldap_add($link, "cn=userC,cn=userB,dc=my-domain,dc=com", array(
"objectclass" => "person",
"cn" => "userC",
"sn" => "testSN3",
@@ -51,10 +52,10 @@ function insert_dummy_data($link, $base) {
));
}
function remove_dummy_data($link, $base) {
ldap_delete($link, "cn=userC,cn=userB,$base");
ldap_delete($link, "cn=userA,$base");
ldap_delete($link, "cn=userB,$base");
ldap_delete($link, "o=test,$base");
function remove_dummy_data($link) {
ldap_delete($link, "cn=userC,cn=userB,dc=my-domain,dc=com");
ldap_delete($link, "cn=userA,dc=my-domain,dc=com");
ldap_delete($link, "cn=userB,dc=my-domain,dc=com");
ldap_delete($link, "dc=my-domain,dc=com");
}
?>
+5 -5
View File
@@ -13,7 +13,7 @@ require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
var_dump(
ldap_add($link, "dc=my-domain,$base", array(
ldap_add($link, "dc=my-domain,dc=com", array(
"objectClass" => array(
"top",
"dcObject",
@@ -23,7 +23,7 @@ var_dump(
)),
ldap_get_entries(
$link,
ldap_search($link, "$base", "(o=my-domain)")
ldap_search($link, "dc=my-domain,dc=com", "(o=my-domain)")
)
);
?>
@@ -34,9 +34,9 @@ require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
ldap_delete($link, "dc=my-domain,$base");
ldap_delete($link, "dc=my-domain,dc=com");
?>
--EXPECTF--
--EXPECT--
bool(true)
array(2) {
["count"]=>
@@ -77,7 +77,7 @@ array(2) {
["count"]=>
int(3)
["dn"]=>
string(%d) "dc=my-domain,%s"
string(19) "dc=my-domain,dc=com"
}
}
===DONE===
+14 -14
View File
@@ -15,12 +15,12 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
// Too few parameters
var_dump(ldap_add());
var_dump(ldap_add($link));
var_dump(ldap_add($link, "$base"));
var_dump(ldap_add($link, "dc=my-domain,dc=com"));
// Too many parameters
var_dump(ldap_add($link, "$base", array(), "Additional data"));
var_dump(ldap_add($link, "dc=my-domain,dc=com", array(), "Additional data"));
var_dump(ldap_add($link, "$base", array()));
var_dump(ldap_add($link, "dc=my-domain,dc=com", array()));
// Invalid DN
var_dump(
@@ -34,14 +34,14 @@ var_dump(
// Duplicate entry
for ($i = 0; $i < 2; $i++)
var_dump(
ldap_add($link, "dc=my-domain,$base", array(
"objectClass" => array(
"top",
"dcObject",
"organization"),
"dc" => "my-domain",
"o" => "my-domain",
))
ldap_add($link, "dc=my-domain,dc=com", array(
"objectClass" => array(
"top",
"dcObject",
"organization"),
"dc" => "my-domain",
"o" => "my-domain",
))
);
var_dump(ldap_error($link), ldap_errno($link));
@@ -64,7 +64,7 @@ var_dump(
// Invalid attribute
var_dump(
ldap_add($link, "$base", array(
ldap_add($link, "dc=my-domain,dc=com", array(
"objectClass" => array(
"top",
"dcObject",
@@ -78,7 +78,7 @@ var_dump(
);
var_dump(
ldap_add($link, "$base", array(array( "Oops"
ldap_add($link, "dc=my-domain,dc=com", array(array( "Oops"
)))
/* Is this correct behaviour to still have "Undefined attribute type" as error/errno?
,
@@ -94,7 +94,7 @@ require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
ldap_delete($link, "dc=my-domain,$base");
ldap_delete($link, "dc=my-domain,dc=com");
?>
--EXPECTF--
Warning: ldap_add() expects exactly 3 parameters, 0 given in %s on line %d
+4 -4
View File
@@ -11,10 +11,10 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
insert_dummy_data($link);
var_dump(
ldap_compare($link, "cn=userA,$base", "sn", "testSN1"),
ldap_compare($link, "cn=userA,$base", "telephoneNumber", "yy-yy-yy-yy-yy")
ldap_compare($link, "cn=userA,dc=my-domain,dc=com", "sn", "testSN1"),
ldap_compare($link, "cn=userA,dc=my-domain,dc=com", "telephoneNumber", "yy-yy-yy-yy-yy")
);
?>
===DONE===
@@ -23,7 +23,7 @@ var_dump(
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECT--
bool(true)
+3 -3
View File
@@ -11,7 +11,7 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
insert_dummy_data($link);
// Too few parameters
var_dump(ldap_compare($link));
@@ -22,7 +22,7 @@ var_dump(ldap_compare($link, $link, $link));
var_dump(ldap_compare($link, $link, $link, $link, "Additional data"));
var_dump(
ldap_compare($link, "cn=userNotAvailable,$base", "sn", "testSN1"),
ldap_compare($link, "cn=userNotAvailable,dc=my-domain,dc=com", "sn", "testSN1"),
ldap_error($link),
ldap_errno($link)
);
@@ -33,7 +33,7 @@ var_dump(
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECTF--
Warning: ldap_compare() expects exactly 4 parameters, 1 given in %s on line %d
+1 -1
View File
@@ -13,7 +13,7 @@ require "connect.inc";
// too many arguments
var_dump(ldap_connect(null, null, null));
var_dump(ldap_connect("ldap://$host:$port/$base"));
var_dump(ldap_connect("ldap://$host:$port/dc=my-domain,dc=com"));
$links = array();
$links[0] = ldap_connect($host, $port);
@@ -12,10 +12,10 @@ require_once('skipifbindfailure.inc');
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
insert_dummy_data($link);
$dn = "$base";
$filter = "(cn=user*)";
$dn = "dc=my-domain,dc=com";
$filter = "(cn=*)";
var_dump(
ldap_control_paged_result($link, 1),
$result = ldap_search($link, $dn, $filter, array('cn')),
@@ -28,7 +28,7 @@ var_dump(
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECTF--
bool(true)
@@ -50,7 +50,7 @@ array(2) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userA,%s"
string(28) "cn=userA,dc=my-domain,dc=com"
}
}
===DONE===
@@ -12,10 +12,10 @@ require_once('skipifbindfailure.inc');
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
insert_dummy_data($link);
$dn = "$base";
$filter = "(cn=user*)";
$dn = "dc=my-domain,dc=com";
$filter = "(cn=*)";
var_dump(
ldap_control_paged_result($link, 2),
$result = ldap_search($link, $dn, $filter, array('cn')),
@@ -28,7 +28,7 @@ var_dump(
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECTF--
bool(true)
@@ -50,7 +50,7 @@ array(3) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userA,%s"
string(28) "cn=userA,dc=my-domain,dc=com"
}
[1]=>
array(4) {
@@ -66,7 +66,7 @@ array(3) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userB,%s"
string(28) "cn=userB,dc=my-domain,dc=com"
}
}
===DONE===
@@ -12,10 +12,10 @@ require_once('skipifbindfailure.inc');
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
insert_dummy_data($link);
$dn = "$base";
$filter = "(cn=user*)";
$dn = "dc=my-domain,dc=com";
$filter = "(cn=*)";
$cookie = '';
var_dump(
ldap_control_paged_result($link, 2, true, $cookie),
@@ -33,7 +33,7 @@ var_dump(
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECTF--
bool(true)
@@ -55,7 +55,7 @@ array(3) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userA,%s"
string(28) "cn=userA,dc=my-domain,dc=com"
}
[1]=>
array(4) {
@@ -71,7 +71,7 @@ array(3) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userB,%s"
string(28) "cn=userB,dc=my-domain,dc=com"
}
}
bool(true)
@@ -94,7 +94,7 @@ array(2) {
["count"]=>
int(1)
["dn"]=>
string(%d) "cn=userC,cn=userB,%s"
string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
}
}
===DONE===
+3 -3
View File
@@ -11,8 +11,8 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
$result = ldap_search($link, "$base", "(objectclass=person)");
insert_dummy_data($link);
$result = ldap_search($link, "dc=my-domain,dc=com", "(objectclass=person)");
var_dump(ldap_count_entries($link, $result));
?>
===DONE===
@@ -21,7 +21,7 @@ var_dump(ldap_count_entries($link, $result));
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECT--
int(3)
+4 -4
View File
@@ -11,7 +11,7 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
ldap_add($link, "dc=my-domain,$base", array(
ldap_add($link, "dc=my-domain,dc=com", array(
"objectClass" => array(
"top",
"dcObject",
@@ -21,8 +21,8 @@ ldap_add($link, "dc=my-domain,$base", array(
));
var_dump(
ldap_delete($link, "dc=my-domain,$base"),
@ldap_search($link, "dc=my-domain,$base", "(o=my-domain)")
ldap_delete($link, "dc=my-domain,dc=com"),
@ldap_search($link, "dc=my-domain,dc=com", "(o=my-domain)")
);
?>
===DONE===
@@ -32,7 +32,7 @@ require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
ldap_delete($link, "dc=my-domain,$base");
ldap_delete($link, "dc=my-domain,dc=com");
?>
--EXPECT--
bool(true)
+2 -2
View File
@@ -17,7 +17,7 @@ var_dump(ldap_delete());
var_dump(ldap_delete($link));
// Too many parameters
var_dump(ldap_delete($link, "$base", "Additional data"));
var_dump(ldap_delete($link, "dc=my-domain,dc=com", "Additional data"));
// Invalid DN
var_dump(
@@ -28,7 +28,7 @@ var_dump(
// Deleting unexisting data
var_dump(
ldap_delete($link, "dc=my-domain,$base"),
ldap_delete($link, "dc=my-domain,dc=com"),
ldap_error($link),
ldap_errno($link)
);
+1 -1
View File
@@ -11,7 +11,7 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
@ldap_add($link, "badDN $base", array(
@ldap_add($link, "badDN dc=my-domain,dc=com", array(
"objectClass" => array(
"top",
"dcObject",
+1 -1
View File
@@ -11,7 +11,7 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
@ldap_add($link, "badDN $base", array(
@ldap_add($link, "badDN dc=my-domain,dc=com", array(
"objectClass" => array(
"top",
"dcObject",
@@ -11,8 +11,8 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
$result = ldap_search($link, "$base", "(objectclass=organization)", array("objectClass"));
insert_dummy_data($link);
$result = ldap_search($link, "dc=my-domain,dc=com", "(objectclass=organization)");
$entry = ldap_first_entry($link, $result);
var_dump(
ldap_first_attribute($link, $entry)
@@ -24,7 +24,7 @@ var_dump(
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECT--
string(11) "objectClass"
+3 -3
View File
@@ -11,8 +11,8 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
$result = ldap_search($link, "$base", "(objectclass=person)");
insert_dummy_data($link);
$result = ldap_search($link, "dc=my-domain,dc=com", "(objectclass=person)");
var_dump(
$entry = ldap_first_entry($link, $result),
ldap_get_values($link, $entry, 'sn')
@@ -24,7 +24,7 @@ var_dump(
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECTF--
resource(%d) of type (ldap result entry)
@@ -10,14 +10,14 @@ Patrick Allaert <patrickallaert@php.net>
<?php
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
ldap_add($link, "cn=userref,$base", array(
insert_dummy_data($link);
ldap_add($link, "cn=userref,dc=my-domain,dc=com", array(
"objectClass" => array("extensibleObject", "referral"),
"cn" => "userref",
"ref" => "cn=userA,$base",
"ref" => "cn=userA,dc=my-domain,dc=com",
));
ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_NEVER);
$result = ldap_search($link, "$base", "(cn=*)");
$result = ldap_search($link, "dc=my-domain,dc=com", "(cn=*)");
var_dump($ref = ldap_first_reference($link, $result));
$refs = null;
ldap_parse_reference($link, $ref, $refs);
@@ -31,13 +31,13 @@ include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
// Referral can only be removed with Manage DSA IT Control
ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, array(array("oid" => "2.16.840.1.113730.3.4.2")));
ldap_delete($link, "cn=userref,$base");
remove_dummy_data($link, $base);
ldap_delete($link, "cn=userref,dc=my-domain,dc=com");
remove_dummy_data($link);
?>
--EXPECTF--
resource(%d) of type (ldap result entry)
array(1) {
[0]=>
string(%d) "cn=userA,%s"
string(28) "cn=userA,dc=my-domain,dc=com"
}
===DONE===
+3 -3
View File
@@ -11,8 +11,8 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
$result = ldap_search($link, "$base", "(objectclass=person)");
insert_dummy_data($link);
$result = ldap_search($link, "dc=my-domain,dc=com", "(objectclass=person)");
var_dump(ldap_free_result($result));
?>
===DONE===
@@ -21,7 +21,7 @@ var_dump(ldap_free_result($result));
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECT--
bool(true)
+21 -10
View File
@@ -11,8 +11,8 @@ Patrick Allaert <patrickallaert@php.net>
require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
$result = ldap_search($link, "$base", "(o=test)");
insert_dummy_data($link);
$result = ldap_search($link, "dc=my-domain,dc=com", "(objectclass=organization)");
$entry = ldap_first_entry($link, $result);
var_dump(
ldap_get_attributes($link, $entry)
@@ -24,31 +24,42 @@ var_dump(
include "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
remove_dummy_data($link);
?>
--EXPECTF--
array(5) {
--EXPECT--
array(7) {
["objectClass"]=>
array(3) {
array(4) {
["count"]=>
int(2)
int(3)
[0]=>
string(3) "top"
[1]=>
string(8) "dcObject"
[2]=>
string(12) "organization"
}
[0]=>
string(11) "objectClass"
["dc"]=>
array(2) {
["count"]=>
int(1)
[0]=>
string(9) "my-domain"
}
[1]=>
string(2) "dc"
["o"]=>
array(2) {
["count"]=>
int(1)
[0]=>
string(4) "test"
string(9) "my-domain"
}
[1]=>
[2]=>
string(1) "o"
["count"]=>
int(2)
int(3)
}
===DONE===
Loaded 100 of 335 files, more files were not shown because too many files have changed in this diff. Show more