Skip to content

Commit d52dbd5

Browse files
committed
Merge branch 'PHP-5.5' of https://git.php.net/repository/php-src into PHP-5.5
# By Adam Harvey (3) and others # Via Adam Harvey (2) and Michael Wallner (1) * 'PHP-5.5' of https://git.php.net/repository/php-src: fix broken sha2 configure tests Fixed minor bug in test. Move NEWS entries to correct version Fix bug #64782: SplFileObject constructor make $context optional Fix bug #65502: DateTimeImmutable::createFromFormat returns DateTime Fix bug #65548: Comparison for DateTimeImmutable doesn't work Tinker with the wording of the short_open_tag description. Fix NEWS: these commits were after 5.5.4 was branched and will be in 5.5.5. Handle CLI server request headers case insensitively. ensure that the defined interpolation method is used by the generic scaling functions Fixed issue #128 (opcache_invalidate segmentation fault) 5.4.21 now
2 parents e5678c9 + 9eaffd3 commit d52dbd5

13 files changed

+190
-58
lines changed

NEWS

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2013, PHP 5.5.5
44

5+
- CLI server:
6+
. Fixed bug #65633 (built-in server treat some http headers as
7+
case-sensitive). (Adam)
8+
9+
- Datetime:
10+
. Fixed bug #65502 (DateTimeImmutable::createFromFormat returns DateTime).
11+
(Boro Sitnikovski)
12+
. Fixed bug #65548 (Comparison for DateTimeImmutable doesn't work).
13+
(Boro Sitnikovski)
14+
15+
- GD
16+
. Ensure that the defined interpolation method is used with the generic
17+
scaling methods. (Pierre)
18+
19+
- OPcache:
20+
. Fixed bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var). (Dmitry)
21+
22+
- SPL:
23+
. Fix bug #64782 (SplFileObject constructor make $context optional / give it
24+
a default value). (Nikita)
25+
526
?? ??? 2013, PHP 5.5.4
627

728
- Core:
@@ -33,7 +54,6 @@ PHP NEWS
3354
- OPCache:
3455
. Fixed bug #65561 (Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4).
3556
(Terry Ellison)
36-
. Fixed bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var). (Dmitry)
3757

3858
- Openssl:
3959
. Fixed bug #64802 (openssl_x509_parse fails to parse subject properly in
@@ -46,8 +66,8 @@ PHP NEWS
4666
session serialize handler that uses plain serialize()). (Yasuo)
4767

4868
- Standard:
49-
. Fix issue with return types of password API helper functions. Found via static
50-
analysis by cjones. (Anthony Ferrara)
69+
. Fix issue with return types of password API helper functions. Found via
70+
static analysis by cjones. (Anthony Ferrara)
5171

5272
22 Aug 2013, PHP 5.5.3
5373

ext/date/php_date.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ const zend_function_entry date_funcs_immutable[] = {
480480
PHP_ME(DateTimeImmutable, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
481481
PHP_ME(DateTime, __wakeup, NULL, ZEND_ACC_PUBLIC)
482482
PHP_ME(DateTimeImmutable, __set_state, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
483-
PHP_ME_MAPPING(createFromFormat, date_create_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
483+
PHP_ME_MAPPING(createFromFormat, date_create_immutable_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
484484
PHP_ME_MAPPING(getLastErrors, date_get_last_errors, arginfo_date_get_last_errors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
485485
PHP_ME_MAPPING(format, date_format, arginfo_date_method_format, 0)
486486
PHP_ME_MAPPING(getTimezone, date_timezone_get, arginfo_date_method_timezone_get, 0)
@@ -2142,27 +2142,21 @@ static zval* date_clone_immutable(zval *object TSRMLS_DC)
21422142

21432143
static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC)
21442144
{
2145-
if (Z_TYPE_P(d1) == IS_OBJECT && Z_TYPE_P(d2) == IS_OBJECT &&
2146-
instanceof_function(Z_OBJCE_P(d1), date_ce_date TSRMLS_CC) &&
2147-
instanceof_function(Z_OBJCE_P(d2), date_ce_date TSRMLS_CC)) {
2148-
php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC);
2149-
php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC);
2145+
php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC);
2146+
php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC);
21502147

2151-
if (!o1->time || !o2->time) {
2152-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to compare an incomplete DateTime object");
2153-
return 1;
2154-
}
2155-
if (!o1->time->sse_uptodate) {
2156-
timelib_update_ts(o1->time, o1->time->tz_info);
2157-
}
2158-
if (!o2->time->sse_uptodate) {
2159-
timelib_update_ts(o2->time, o2->time->tz_info);
2160-
}
2161-
2162-
return (o1->time->sse == o2->time->sse) ? 0 : ((o1->time->sse < o2->time->sse) ? -1 : 1);
2148+
if (!o1->time || !o2->time) {
2149+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to compare an incomplete DateTime or DateTimeImmutable object");
2150+
return 1;
2151+
}
2152+
if (!o1->time->sse_uptodate) {
2153+
timelib_update_ts(o1->time, o1->time->tz_info);
2154+
}
2155+
if (!o2->time->sse_uptodate) {
2156+
timelib_update_ts(o2->time, o2->time->tz_info);
21632157
}
21642158

2165-
return 1;
2159+
return (o1->time->sse == o2->time->sse) ? 0 : ((o1->time->sse < o2->time->sse) ? -1 : 1);
21662160
}
21672161

21682162
static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_DC)

ext/date/tests/bug65502.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Test for bug #65502: DateTimeImmutable::createFromFormat returns DateTime
3+
--CREDITS--
4+
Boro Sitnikovski <buritomath@yahoo.com>
5+
--INI--
6+
date.timezone = UTC
7+
--FILE--
8+
<?php
9+
echo get_class(DateTimeImmutable::createFromFormat('j-M-Y', '12-Sep-2013'));
10+
?>
11+
--EXPECT--
12+
DateTimeImmutable

ext/date/tests/bug65548.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Test for bug #65548: Comparison for DateTimeImmutable doesn't work
3+
--CREDITS--
4+
Boro Sitnikovski <buritomath@yahoo.com>
5+
--INI--
6+
date.timezone = UTC
7+
--FILE--
8+
<?php
9+
$iToday = new DateTimeImmutable('today');
10+
$iTomorrow = new DateTimeImmutable('tomorrow');
11+
12+
$mToday = new DateTime('today');
13+
$mTomorrow = new DateTime('tomorrow');
14+
15+
var_dump($iToday < $iTomorrow);
16+
var_dump($iToday == $iTomorrow);
17+
var_dump($iToday > $iTomorrow);
18+
19+
var_dump($iToday == $mToday);
20+
var_dump($iToday === $mToday);
21+
22+
var_dump($iToday < $mTomorrow);
23+
var_dump($iToday == $mTomorrow);
24+
var_dump($iToday > $mTomorrow);
25+
?>
26+
--EXPECT--
27+
bool(true)
28+
bool(false)
29+
bool(false)
30+
bool(true)
31+
bool(false)
32+
bool(true)
33+
bool(false)
34+
bool(false)

ext/gd/libgd/gd_interpolation.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,13 +1065,15 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt
10651065
if (tmp_im == NULL) {
10661066
return NULL;
10671067
}
1068+
gdImageSetInterpolationMethod(tmp_im, src->interpolation_id);
10681069
_gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height);
10691070

10701071
dst = gdImageCreateTrueColor(new_width, new_height);
10711072
if (dst == NULL) {
10721073
gdFree(tmp_im);
10731074
return NULL;
10741075
}
1076+
gdImageSetInterpolationMethod(dst, src->interpolation_id);
10751077
_gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height);
10761078
gdFree(tmp_im);
10771079

@@ -1086,8 +1088,9 @@ gdImagePtr Scale(const gdImagePtr src, const unsigned int src_width, const unsig
10861088
if (tmp_im == NULL) {
10871089
return NULL;
10881090
}
1089-
_gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height);
1091+
gdImageSetInterpolationMethod(tmp_im, src->interpolation_id);
10901092

1093+
_gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height);
10911094
_gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height);
10921095

10931096
gdFree(tmp_im);

ext/opcache/ZendAccelerator.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,10 @@ int zend_accel_invalidate(const char *filename, int filename_len, zend_bool forc
10621062
realpath = accelerator_orig_zend_resolve_path(filename, filename_len TSRMLS_CC);
10631063
#endif
10641064

1065+
if (!realpath) {
1066+
return FAILURE;
1067+
}
1068+
10651069
persistent_script = zend_accel_hash_find(&ZCSG(hash), realpath, strlen(realpath) + 1);
10661070
if (persistent_script && !persistent_script->corrupted) {
10671071
zend_file_handle file_handle;

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,7 @@ SPL_METHOD(SplFileObject, __construct)
22902290
intern->u.file.open_mode = NULL;
22912291
intern->u.file.open_mode_len = 0;
22922292

2293-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbr",
2293+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbr!",
22942294
&intern->file_name, &intern->file_name_len,
22952295
&intern->u.file.open_mode, &intern->u.file.open_mode_len,
22962296
&use_include_path, &intern->u.file.zcontext) == FAILURE) {

ext/spl/tests/bug64782.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #64782: SplFileObject constructor make $context optional / give it a default value
3+
--FILE--
4+
<?php
5+
6+
var_dump(new SplFileObject(__FILE__, "r", false, null));
7+
8+
?>
9+
--EXPECTF--
10+
object(SplFileObject)#1 (%d) {
11+
["pathName":"SplFileInfo":private]=>
12+
string(%d) "%s/bug64782.php"
13+
["fileName":"SplFileInfo":private]=>
14+
string(12) "bug64782.php"
15+
["openMode":"SplFileObject":private]=>
16+
string(1) "r"
17+
["delimiter":"SplFileObject":private]=>
18+
string(1) ","
19+
["enclosure":"SplFileObject":private]=>
20+
string(1) """
21+
}

ext/standard/config.m4

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ AC_TRY_RUN([
182182
183183
main() {
184184
#if HAVE_CRYPT
185-
char salt[30], answer[80];
186-
187-
salt[0]='$'; salt[1]='6'; salt[2]='$'; salt[3]='$'; salt[4]='b'; salt[5]='a'; salt[6]='r'; salt[7]='\0';
185+
char salt[21], answer[21+86];
186+
187+
strcpy(salt,"\$6\$rasmuslerdorf\$");
188188
strcpy(answer, salt);
189-
strcpy(&answer[29],"$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.");
190-
exit (strcmp((char *)crypt("foo",salt),answer));
189+
strcat(answer, "EeHCRjm0bljalWuALHSTs1NB9ipEiLEXLhYeXdOpx22gmlmVejnVXFhd84cEKbYxCo.XuUTrW.RLraeEnsvWs/");
190+
exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
191191
#else
192192
exit(0);
193193
#endif
@@ -211,12 +211,13 @@ AC_TRY_RUN([
211211
212212
main() {
213213
#if HAVE_CRYPT
214-
char salt[30], answer[80];
215-
salt[0]='$'; salt[1]='5'; salt[2]='$'; salt[3]='$'; salt[4]='s'; salt[5]='a'; salt[6]='l'; salt[7]='t'; salt[8]='s'; salt[9]='t'; salt[10]='r'; salt[11]='i'; salt[12]='n'; salt[13]='g'; salt[14]='\0';
216-
strcat(salt,"");
214+
char salt[21], answer[21+43];
215+
216+
strcpy(salt,"\$5\$rasmuslerdorf\$");
217217
strcpy(answer, salt);
218-
strcpy(&answer[29], "$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5");
219-
exit (strcmp((char *)crypt("foo",salt),answer));
218+
strcat(answer, "cFAm2puLCujQ9t.0CxiFIIvFi4JyQx5UncCt/xRIX23");
219+
exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
220+
220221
#else
221222
exit(0);
222223
#endif

php.ini-development

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,12 @@
197197
engine = On
198198

199199
; This directive determines whether or not PHP will recognize code between
200-
; <? and ?> tags as PHP source which should be processed as such. It's been
201-
; recommended for several years that you not use the short tag "short cut" and
202-
; instead to use the full <?php and ?> tag combination. With the wide spread use
203-
; of XML and use of these tags by other languages, the server can become easily
204-
; confused and end up parsing the wrong code in the wrong context. But because
205-
; this short cut has been a feature for such a long time, it's currently still
206-
; supported for backwards compatibility, but we recommend you don't use them.
200+
; <? and ?> tags as PHP source which should be processed as such. It is
201+
; generally recommended that <?php and ?> should be used and that this feature
202+
; should be disabled, as enabling it may result in issues when generating XML
203+
; documents, however this remains supported for backward compatibility reasons.
204+
; Note that this directive does not control the <?= shorthand tag, which can be
205+
; used regardless of this directive.
207206
; Default Value: On
208207
; Development Value: Off
209208
; Production Value: Off

php.ini-production

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,12 @@
197197
engine = On
198198

199199
; This directive determines whether or not PHP will recognize code between
200-
; <? and ?> tags as PHP source which should be processed as such. It's been
201-
; recommended for several years that you not use the short tag "short cut" and
202-
; instead to use the full <?php and ?> tag combination. With the wide spread use
203-
; of XML and use of these tags by other languages, the server can become easily
204-
; confused and end up parsing the wrong code in the wrong context. But because
205-
; this short cut has been a feature for such a long time, it's currently still
206-
; supported for backwards compatibility, but we recommend you don't use them.
200+
; <? and ?> tags as PHP source which should be processed as such. It is
201+
; generally recommended that <?php and ?> should be used and that this feature
202+
; should be disabled, as enabling it may result in issues when generating XML
203+
; documents, however this remains supported for backward compatibility reasons.
204+
; Note that this directive does not control the <?= shorthand tag, which can be
205+
; used regardless of this directive.
207206
; Default Value: On
208207
; Development Value: Off
209208
; Production Value: Off

sapi/cli/php_cli_server.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c
412412
{
413413
{
414414
char **val;
415-
if (SUCCESS == zend_hash_find(&client->request.headers, "Host", sizeof("Host"), (void**)&val)) {
415+
if (SUCCESS == zend_hash_find(&client->request.headers, "host", sizeof("host"), (void**)&val)) {
416416
smart_str_appendl_ex(buffer, "Host", sizeof("Host") - 1, persistent);
417417
smart_str_appendl_ex(buffer, ": ", sizeof(": ") - 1, persistent);
418418
smart_str_appends_ex(buffer, *val, persistent);
@@ -568,7 +568,7 @@ static char *sapi_cli_server_read_cookies(TSRMLS_D) /* {{{ */
568568
{
569569
php_cli_server_client *client = SG(server_context);
570570
char **val;
571-
if (FAILURE == zend_hash_find(&client->request.headers, "Cookie", sizeof("Cookie"), (void**)&val)) {
571+
if (FAILURE == zend_hash_find(&client->request.headers, "cookie", sizeof("cookie"), (void**)&val)) {
572572
return NULL;
573573
}
574574
return *val;
@@ -1566,12 +1566,9 @@ static int php_cli_server_client_read_request_on_header_value(php_http_parser *p
15661566
return 1;
15671567
}
15681568
{
1569-
char *header_name = client->current_header_name;
1570-
size_t header_name_len = client->current_header_name_len;
1571-
char c = header_name[header_name_len];
1572-
header_name[header_name_len] = '\0';
1573-
zend_hash_add(&client->request.headers, header_name, header_name_len + 1, &value, sizeof(char *), NULL);
1574-
header_name[header_name_len] = c;
1569+
char *header_name = zend_str_tolower_dup(client->current_header_name, client->current_header_name_len);
1570+
zend_hash_add(&client->request.headers, header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL);
1571+
efree(header_name);
15751572
}
15761573

15771574
if (client->current_header_name_allocated) {
@@ -1729,7 +1726,7 @@ static void php_cli_server_client_populate_request_info(const php_cli_server_cli
17291726
request_info->post_data = client->request.content;
17301727
request_info->content_length = request_info->post_data_length = client->request.content_len;
17311728
request_info->auth_user = request_info->auth_password = request_info->auth_digest = NULL;
1732-
if (SUCCESS == zend_hash_find(&client->request.headers, "Content-Type", sizeof("Content-Type"), (void**)&val)) {
1729+
if (SUCCESS == zend_hash_find(&client->request.headers, "content-type", sizeof("content-type"), (void**)&val)) {
17331730
request_info->content_type = *val;
17341731
}
17351732
} /* }}} */
@@ -1967,7 +1964,7 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
19671964
static int php_cli_server_request_startup(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) { /* {{{ */
19681965
char **auth;
19691966
php_cli_server_client_populate_request_info(client, &SG(request_info));
1970-
if (SUCCESS == zend_hash_find(&client->request.headers, "Authorization", sizeof("Authorization"), (void**)&auth)) {
1967+
if (SUCCESS == zend_hash_find(&client->request.headers, "authorization", sizeof("authorization"), (void**)&auth)) {
19711968
php_handle_auth_data(*auth TSRMLS_CC);
19721969
}
19731970
SG(sapi_headers).http_response_code = 200;

sapi/cli/tests/bug65633.phpt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
Bug #65633 (built-in server treat some http headers as case-sensitive)
3+
--SKIPIF--
4+
<?php
5+
include "skipif.inc";
6+
?>
7+
--FILE--
8+
<?php
9+
include "php_cli_server.inc";
10+
php_cli_server_start(<<<'PHP'
11+
var_dump($_COOKIE, $_SERVER['HTTP_FOO']);
12+
PHP
13+
);
14+
15+
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
16+
$port = intval($port)?:80;
17+
18+
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
19+
if (!$fp) {
20+
die("connect failed");
21+
}
22+
23+
if(fwrite($fp, <<<HEADER
24+
GET / HTTP/1.1
25+
cookie: foo=bar
26+
foo: bar
27+
28+
29+
HEADER
30+
)) {
31+
while (!feof($fp)) {
32+
echo fgets($fp);
33+
}
34+
}
35+
36+
fclose($fp);
37+
?>
38+
--EXPECTF--
39+
HTTP/1.1 200 OK
40+
Connection: close
41+
X-Powered-By: %s
42+
Content-type: text/html
43+
44+
array(1) {
45+
["foo"]=>
46+
string(3) "bar"
47+
}
48+
string(3) "bar"

0 commit comments

Comments
 (0)