PHP Release 5.2.1


PHP 5.2.1 Release Announcement

The PHP development team would like to announce the immediate availability of PHP 5.2.1. This release is a major stability and security enhancement of the 5.X branch, and all users are strongly encouraged to upgrade to it as soon as possible.

Security Enhancements and Fixes in PHP 5.2.1:

  • Fixed possible safe_mode & open_basedir bypasses inside the session extension.
  • Prevent search engines from indexing the phpinfo() page.
  • Fixed a number of input processing bugs inside the filter extension.
  • Fixed unserialize() abuse on 64 bit systems with certain input strings.
  • Fixed possible overflows and stack corruptions in the session extension.
  • Fixed an underflow inside the internal sapi_header_op() function.
  • Fixed allocation bugs caused by attempts to allocate negative values in some code paths.
  • Fixed possible stack overflows inside zip, imap & sqlite extensions.
  • Fixed several possible buffer overflows inside the stream filters.
  • Fixed non-validated resource destruction inside the shmop extension.
  • Fixed a possible overflow in the str_replace() function.
  • Fixed possible clobbering of super-globals in several code paths.
  • Fixed a possible information disclosure inside the wddx extension.
  • Fixed a possible string format vulnerability in *print() functions on 64 bit systems.
  • Fixed a possible buffer overflow inside mail() and ibase_{delete,add,modify}_user() functions.
  • Fixed a string format vulnerability inside the odbc_result_all() function.
  • Memory limit is now enabled by default.
  • Added internal heap protection.
  • Extended filter extension support for $_SERVER in CGI and apache2 SAPIs.

The majority of the security vulnerabilities discovered and resolved can in most cases be only abused by local users and cannot be triggered remotely. However, some of the above issues can be triggered remotely in certain situations, or exploited by malicious local users on shared hosting setups utilizing PHP as an Apache module. Therefore, we strongly advise all users of PHP, regardless of the version to upgrade to 5.2.1 release as soon as possible. PHP 4.4.5 with equivalent security corrections is available as well.

The key improvements of PHP 5.2.1 include:

  • Several performance improvements in the engine, streams API and some Windows specific optimizations.
  • PDO_MySQL now uses buffered queries by default and emulates prepared statements to bypass limitations of MySQL's prepared statement API.
  • Many improvements and enhancements to the filter and zip extensions.
  • Memory limit is now always enabled, this includes Windows builds, with a default limit of 128 megabytes.
  • Added several performance optimizations using faster Win32 APIs (this change means that PHP no longer supports Windows 98).
  • FastCGI speed optimized build of PHP for Windows made available for downloading.
  • Over 180 bug fixes.

For users upgrading from PHP 5.0 and PHP 5.1, an upgrade guide is available here, detailing the changes between those releases and PHP 5.2.1.

For a full list of changes in PHP 5.2.1, see the ChangeLog.

Source Code
Change Logs
moved extensions to pecl
  • Removed double "wrong parameter count" warnings in various functions.
  • ext/informix
  • Changed double-to-string utilities to use BSD implementation.
  • Updated bundled libcURL to version 7.16.0 in the Windows distro.
  • Updated timezone database to version 2006.16.
  • cgi.* and fastcgi.* directives are moved to INI subsystem. The new directive cgi.check_shebang_line can be used to omitting check for "#! /usr/bin/php" line. .
  • Improved proc_open(). Now on Windows it can run external commands not through CMD.EXE.
  • VCWD_REALPATH() is improved to use realpath cache without VIRTUAL_DIR.
  • ext/bcmath initialization code is moved from request startup to module startup.
  • Zend Memory Manager Improvements
  • use HeapAlloc() instead of VirtualAlloc()
  • use "win32" storage manager on Windows by default
  • Zip Extension Improvements
  • Fixed leak in statName and stateIndex
  • Fixed return setComment
  • Added addEmptyDir method
  • Filter Extension Improvements
  • Fixed a bug when callback function returns a non-modified value.
  • Added filter support for $_SERVER in cgi/apache2 sapis.
  • Make sure PHP_SELF is filtered in Apache 1 sapi.
  • Fixed bug #39358 .
  • Added "default" option that allows a default value to be set for an invalid or missing value.
  • Invalid filters fails instead of returning unsafe value
  • Fixed possible double encoding problem with sanitizing filters
  • Make use of space-strict strip_tags() function
  • Fixed whitespace trimming
  • Added support for FastCGI environment variables.
  • PDO_MySQL Extension Improvements
  • Enabled buffered queries by default.
  • Enabled prepared statement emulation by default.
  • Small optimization of the date() function.
  • Optimized the internal is_numeric_string() function.
  • Optimized array functions utilizing php_splice().
  • Windows related optimizations
  • COM initialization/deinitialization are done only if necessary
  • removed unnecessary checks for ISREG file and corresponding stat() calls
  • opendir() is reimplementation using GetFistFile/GetNextFile those are faster then _findfirst/_findnext
  • implemented registry cache that prevent registry lookup on each request. In case of modification of corresponding registry-tree PHP will reload it automatic
  • start timeout thread only if necessary
  • stat() is reimplementation using GetFileAttributesEx(). The new implementation is faster then implementation in MS VC CRT, but it doesn't support Windows 95.
  • Streams optimization
  • removed unnecessary ftell() calls
  • disabled calls to read() after EOF
  • Fixed incorrect function names on FreeBSD where inet_pton() was named __inet_pton() and inet_ntop() was named __inet_ntop().
  • Fixed FastCGI impersonation for persistent connections on Windows.
  • Fixed wrong signature initialization in imagepng
  • Fixed ftruncate() with negative size on FreeBSD.
  • Fixed segfault in RegexIterator when given invalid regex.
  • Fixed segfault in SplFileObject->openFile()->getPathname().
  • Fixed segfault in ZTS mode when OCI8 statements containing sub-statements are destroyed in wrong order.
  • Fixed the validate email filter so that the letter "v" can also be used in the user part of the email address.
  • Fixed bug #40297 (compile failure in ZTS mode when collections support is missing).
  • Fixed bug #40285 (The PDO prepare parser goes into an infinite loop in some instances).
  • Fixed bug #40274 (Sessions fail with numeric root keys).
  • Fixed bug #40259 (ob_start call many times - memory error).
  • Fixed bug #40231 (file_exists incorrectly reports false).
fixed bug #40228 (ziparchive
  • Fixed bug #40200 (The FastCgi version has different realpath results than thread safe version).
  • Fixed bug #40191 (use of array_unique() with objects triggers segfault).
  • Fixed bug #40189 (possible endless loop in zlib.inflate stream filter).
  • Fixed bug #40169 (CURLOPT_TCP_NODELAY only available in curl >= 7.11.2).
  • Fixed bug #40129 (iconv extension doesn't compile with CodeWarrior on Netware).
  • Fixed bug #40127 (apache2handler doesn't compile on Netware).
  • Fixed bug #40121 (PDO_DBLIB driver wont free statements).
  • Fixed bug #40098 (php_fopen_primary_script() not thread safe).
  • Fixed bug #40092 (chroot() doesn't clear realpath cache).
  • Fixed bug #40091 (spl_autoload_register with 2 instances of the same class).
  • Fixed bug #40083 (milter SAPI functions always return false/null).
  • Fixed bug #40079 (php_get_current_user() not thread safe).
  • Fixed bug #40078 (ORA-01405 when fetching NULL values using oci_bind_array_by_name()).
fixed bug #40076 (zend_alloc.c
  • Fixed bug #40073 (exif_read_data dies on certain images).
  • Fixed bug #40036 (empty() does not work correctly with ArrayObject when using ARRAY_AS_PROPS).
  • Fixed bug #40012 (php_date.c doesn't compile on Netware).
  • Fixed bug #40009 (http_build_query(array()) returns NULL).
  • Fixed bug #40002 (Try/Catch performs poorly).
  • Fixed bug #39993 (tr_TR.UTF-8 locale has problems with PHP).
  • Fixed bug #39990 (Cannot "foreach" over overloaded properties).
  • Fixed bug #39988 (type argument of oci_define_by_name() is ignored).
  • Fixed bug #39984 (redirect response code in header() could be ignored in CGI sapi).
  • Fixed bug #39979 (PGSQL_CONNECT_FORCE_NEW will causes next connect to establish a new connection).
  • Fixed bug #39971 (pg_insert/pg_update do not allow now() to be used for timestamp fields).
  • Fixed bug #39969 (ini setting short_open_tag has no effect when using --enable-maintainer-zts).
  • Fixed bug #39952 (zip ignoring --with-libdir on zlib checks)
  • Fixed bug #39944 (References broken).
  • Fixed bug #39935 (Extensions tidy,mcrypt,mhash,pdo_sqlite ignores --with-libdir).
  • Fixed bug #39903 (Notice message when executing __halt_compiler() more than once).
  • Fixed bug #39898 (FILTER_VALIDATE_URL validates \r\n\t etc).
  • Fixed bug #39890 (using autoconf 2.6x and --with-layout=GNU breaks PEAR install path).
fixed bug #39884 (reflectionparameter
  • Fixed bug #39878 (CURL doesn't compile on Sun Studio Pro).
  • Fixed bug #39873 (number_format() breaks with locale & decimal points).
  • Fixed bug #39869 (safe_read does not initialize errno).
  • Fixed bug #39850 (SplFileObject throws contradictory/wrong error messages when trying to open "php://wrong").
  • Fixed bug #39846 (Invalid IPv4 treated as valid).
  • Fixed bug #39845 (Persistent connections generate a warning in pdo_pgsql).
fixed bug #39832 (soap server
  • Fixed bug #39825 (foreach produces memory error).
  • Fixed bug #39816 (apxs2filter ignores httpd.conf & .htaccess php config settings).
  • Fixed bug #39815 (SOAP double encoding is not locale-independent).
  • Fixed bug #39797 (virtual() does not reset changed INI settings).
  • Fixed bug #39795 (build fails on AIX because crypt_r() uses different data struct).
  • Fixed bug #39791 (Crash in strtotime() on overly long relative date multipliers).
  • Fixed bug #39787 (PHP doesn't work with Apache 2.3). .
  • Fixed bug #39782 (setTime() on a DateTime constructed with a Weekday yields incorrect results).
  • Fixed bug #39780 (PNG image with CRC/data error raises fatal error)
  • Fixed bug #39779 (Enable AUTH PLAIN mechanism in underlying libc-client).
  • Fixed bug #39775 ("Indirect modification ..." message is not shown).
  • Fixed bug #39763 (magic quotes are applied twice by ext/filter in parse_str()).
  • Fixed bug #39760 (cloning fails on nested SimpleXML-Object).
  • Fixed bug #39759 (Can't use stored procedures fetching multiple result sets in pdo_mysql).
  • Fixed bug #39754 (Some POSIX extension functions not thread safe).
  • Fixed bug #39751 (putenv crash on Windows).
  • Fixed bug #39732 (oci_bind_array_by_name doesn't work on Solaris 64bit).
  • Fixed bug #39724 (Broken build due to spl/filter usage of pcre extension).
  • Fixed bug #39718 (possible crash if assert.callback is set in ini).
  • Fixed bug #39702 (php crashes in the allocator on linux-m68k).
  • Fixed bug #39685 (iconv() - undefined function).
  • Fixed bug #39673 (file_get_contents causes bus error on certain offsets).
  • Fixed bug #39663 (Memory leak in pg_get_notify() and a possible memory corruption on Windows in pgsql and pdo_pgsql extensions).
  • Fixed bug #39662 (Segfault when calling asXML() of a cloned SimpleXMLElement).
  • Fixed bug #39656 (crash when calling fetch() on a PDO statment object after closeCursor()).
  • Fixed bug #39653 (ext/dba doesn't check for db-4.5 and db-4.4 when db4 support is enabled).
  • Fixed bug #39652 (Wrong negative results from memory_get_usage()).
  • Fixed bug #39648 (Implementation of PHP functions chown() and chgrp() are not thread safe).
  • Fixed bug #39640 (Segfault with "Allowed memory size exhausted").
  • Fixed bug #39625 (Apache crashes on importStylesheet call).
  • Fixed bug #39623 (thread safety fixes on *nix for putenv() & mime_magic).
  • Fixed bug #39621 (str_replace() is not binary safe on strings with equal length).
  • Fixed bug #39613 (Possible segfault in imap initialization due to missing module dependency).
  • Fixed bug #39606 (Use of com.typelib_file in PHP.ini STILL causes A/V).
  • Fixed bug #39602 (Invalid session.save_handler crashes PHP).
  • Fixed bug #39596 (Creating Variant of type VT_ARRAY).
  • Fixed bug #39583 (ftp_put() does not change transfer mode to ASCII).
  • Fixed bug #39576 (array_walk() doesn't separate user data zval).
  • Fixed bug #39575 (move_uploaded_file() no longer working (safe mode related)).
fixed bug #39564 (pdo
  • Fixed bug #39548 (ZMSG_LOG_SCRIPT_NAME not routed to OutputDebugString() on Windows).
  • Fixed bug #39538 (fgetcsv can't handle starting newlines and trailing odd number of backslashes).
  • Fixed bug #39534 (Error in maths to calculate of ZEND_MM_ALIGNED_MIN_HEADER_SIZE).
  • Fixed bug #39527 (Failure to retrieve results when multiple unbuffered, prepared statements are used in pdo_mysql).
  • Fixed bug #39508 (imagefill crashes with small images 3 pixels or less).
fixed bug #39506 (archive corrupt with ziparchive
  • Fixed bug #39504 (xmlwriter_write_dtd_entity() creates Attlist tag, not entity).
  • Fixed bug #39483 (Problem with handling of \ char in prepared statements).
  • Fixed bug #39458 (ftp_nlist() returns false on empty dirs).
  • Fixed bug #39454 (Returning a SOAP array segfaults PHP).
  • Fixed bug #39450 (getenv() fills other super-globals).
  • Fixed bug #39449 (Overloaded array properties do not work correctly).
  • Fixed bug #39445 (Calling debug_backtrace() in the __toString() function produces a crash).
fixed bug #39438 (fatal error
  • Fixed bug #39435 ('foo' instanceof bar gives invalid opcode error).
  • Fixed bug #39414 (Syntax error while compiling with Sun Workshop Complier).
  • Fixed bug #39398 (Booleans are not automatically translated to integers).
  • Fixed bug #39394 (Missing check for older variants of openssl).
  • Fixed bug #39367 (clearstatcache() doesn't clear realpath cache).
  • Fixed bug #39366 (imagerotate does not use alpha with angle > 45 degrees)
  • Fixed bug #39364 (Removed warning on empty haystack inside mb_strstr()).
  • Fixed bug #39362 (Added an option to imap_open/imap_reopen to control the number of connection retries).
  • Fixed bugs #39361 & #39400 (mbstring function overloading problem).
  • Fixed bug #39354 (Allow building of curl extension against libcurl 7.16.0).
  • Fixed bug #39350 (crash with implode("\n", array(false))).
  • Fixed bug #39344 (Unnecessary calls to OnModify callback routine for an extension INI directive).
  • Fixed bug #39320 (ZEND_HASH_APPLY_STOP causes deletion).
  • Fixed bug #39313 (spl_autoload triggers Fatal error).
  • Fixed bug #39300 (make install fails if wget is not available).
  • Fixed bug #39297 (Memory corruption because of indirect modification of overloaded array).
  • Fixed bug #39286 (misleading error message when invalid dimensions are given)
  • Fixed bug #39273 (imagecopyresized may ignore alpha channel)
  • Fixed bug #39265 (Fixed path handling inside mod_files.sh).
  • Fixed bug #39217 (serialNumber might be -1 when the value is too large).
  • Fixed bug #39215 (Inappropriate close of stdin/stdout/stderr).
  • Fixed bug #39201 (Possible crash in Apache 2 with 413 ErrorHandler).
  • Fixed bug #39151 (Parse error in recursiveiteratoriterator.php).
  • Fixed bug #39121 (Incorrect return array handling in non-wsdl soap client).
  • Fixed bug #39090 (DirectoryFilterDots doxygen docs and example is wrong).
  • Fixed bug #38852 (XML-RPC Breaks iconv).
  • Fixed bug #38770 (unpack() broken with longs on 64 bit machines). .
  • Fixed bug #38698 (for some keys cdbmake creates corrupted db and cdb can't read valid db).
  • Fixed bug #38680 (Added missing handling of basic types in json_decode).
  • Fixed bug #38604 (Fixed request time leak inside foreach() when iterating through virtual properties).
  • Fixed bug #38602 (header( "HTTP/1.0 ..." ) does not change proto version).
  • Fixed bug #38542 (proc_get_status() returns wrong PID on windows).
  • Fixed bug #38536 (SOAP returns an array of values instead of an object).
  • Fixed bug #38456 (Apache2 segfaults when virtual() is called in .php ErrorDocument).
  • Fixed bug #38325 (spl_autoload_register() gives wrong line for "class not found").
  • Fixed bug #38319 (Remove bogus warnings from persistent PDO connections).
  • Fixed bug #38274 (Memlimit fatal error sent to "wrong" stderr when using fastcgi).
  • Fixed bug #38252 (Incorrect PDO error message on invalid default fetch mode).
  • Fixed bug #37927 (Prevent trap when COM extension processes argument of type VT_DISPATCH|VT_REF)
  • Fixed bug #37773 (iconv_substr() gives "Unknown error" when string length = 1").
  • Fixed bug #37627 (session save_path check checks the parent directory).
  • Fixed bug #37619 (proc_open() closes stdin on fork() failure).
  • Fixed bug #37588 (COM Property propputref converts to PHP function and can't be accesed).
  • Fixed bug #36975 (natcasesort() causes array_pop() to misbehave).
  • Fixed bug #36812 (pg_execute() modifies input array).
  • Fixed bug #36798 (Error parsing named parameters with queries containing high-ascii chars).
  • Fixed bug #36644 (possible crash in variant_date_from_timestamp()).
  • Fixed bug #36427 (proc_open() / proc_close() leak handles on windows).
  • Fixed bug #36392 (wrong number of decimal digits with %e specifier in sprintf).
  • Fixed bug #36214 (__get method works properly only when conditional operator is used).
  • Fixed bug #35634 (Erroneous "Class declarations may not be nested" error raised).
  • Fixed bug #35106 (nested foreach fails when array variable has a reference).
  • Fixed bug #34564 (COM extension not returning modified "out" argument)
  • Fixed bug #33734 (Something strange with COM Object).
  • Fixed bug #33386 (ScriptControl only sees last function of class).
  • Fixed bug #33282 (Re-assignment by reference does not clear the is_ref flag)
  • Fixed bug #30074 (apparent symbol table error with extract($blah, EXTR_REFS))
  • Fixed bug #29840 (is_executable() does not honor safe_mode_exec_dir setting).
To Top