Skip to content

Commit 4fc7dc6

Browse files
committed
Merge branch 'master' into str_size_and_int64
* master: (79 commits) ldap_escape() notes Increment version number, since this will be 5.5.6. Added Zend Debugger to the note about the load order (by trash4you at online dot de) Added a LICENSE file to make it easier for PECL binary distributions to conform with the license. Fix Coverity issue reporting wrong sizeof() Fixed bug #65939 (Space before ";" breaks php.ini parsing). (brainstorm at nopcode dot org) exif NEWS add tests for bug #62523 Merged PR #293 (Exif crash on unknown encoding was fixed) By: Draal Conflicts: configure.in main/php_version.h fix bug #65936 (dangling context pointer causes crash) remove TRAVIS check in test source Fixed compilation warning Just SKIP that test on travis Fixed issue #115 (path issue when using phar). fix memory leak on error (from Coverity scan) fix argument type & remove warning fix const warnings in intl methods Fix coverity issue with -1 returned by findOffset not being handled by getPreferredTag fix possibility of access to *storedType without initialization Fix coverity issue with -1 returned by findOffset not being handled by getPreferredTag ... Conflicts: Zend/zend_compile.c ext/intl/collator/collator_create.c ext/intl/locale/locale_methods.c ext/intl/msgformat/msgformat_format.c ext/intl/msgformat/msgformat_parse.c
2 parents f0fdb82 + dfe4b15 commit 4fc7dc6

File tree

126 files changed

+1053
-906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1053
-906
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ PHP NEWS
4343
- Openssl:
4444
. Added crypto_method option for the ssl stream context. (Martin Jansen)
4545
. Added certificate fingerprint support. (Tjerk Meesters)
46+
. Added explicit TLSv1.1 and TLSv1.2 stream transports. (Daniel Lowrey)
4647
. Fixed bug #65729 (CN_match gives false positive). (Tjerk Meesters)
4748

4849
- PDO_pgsql:

UPGRADING

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ PHP X.Y UPGRADE NOTES
7979
- Openssl:
8080
Added string openssl_x509_fingerprint($x509, $type, $binary).
8181

82+
- LDAP:
83+
Added ldap_escape($value, $ignore = "", $flags = 0).
84+
8285
========================================
8386
6. New Classes and Interfaces
8487
========================================
@@ -113,6 +116,9 @@ PHP X.Y UPGRADE NOTES
113116
9. New Global Constants
114117
========================================
115118

119+
- LDAP:
120+
LDAP_ESCAPE_FILTER int(1)
121+
LDAP_ESCAPE_DN int(2)
116122

117123
========================================
118124
10. Changes to INI File Handling

Zend/RFCs/003.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Modified: 2001-09-17
99
1. Background/Need
1010
==================
1111

12-
Many internal function of PHP will reject parameters because of their
12+
Many internal functions of PHP will reject parameters because of their
1313
type (the array and variable function come to mind). For userland
1414
this is not an easy task as there is no uniform way to do it. An
1515
addition to the engine for requiring loose types would allow
16-
delevopers to know that the data passed to their functions is of the
16+
developers to know that the data passed to their functions are of the
1717
correct type and reduce the need for duplicating the same code in
1818
every function to check for the type of data.
1919

@@ -57,7 +57,7 @@ function foo (array $var){
5757
===========
5858

5959
Mis-matches in type should be reported as fatal errors and should halt
60-
the execution of a script as that function can not be run and code
60+
the execution of a script as that function cannot be run and code
6161
following could not reliably run.
6262

6363

Zend/tests/bug65911.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #65911 (scope resolution operator - strange behavior with $this)
3+
--FILE--
4+
<?php
5+
class A {}
6+
7+
class B
8+
{
9+
public function go()
10+
{
11+
$this->foo = 'bar';
12+
echo A::$this->foo; // should not output 'bar'
13+
}
14+
}
15+
16+
$obj = new B();
17+
$obj->go();
18+
?>
19+
--EXPECTF--
20+
Fatal error: Access to undeclared static property: A::$this in %s on line %d

Zend/zend_compile.c

Lines changed: 137 additions & 136 deletions
Large diffs are not rendered by default.

Zend/zend_language_parser.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ inner_statement:
271271
statement
272272
| function_declaration_statement
273273
| class_declaration_statement
274-
| T_HALT_COMPILER '(' ')' ';' { zend_error(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used from the outermost scope"); }
274+
| T_HALT_COMPILER '(' ')' ';' { zend_error_noreturn(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used from the outermost scope"); }
275275
;
276276

277277

@@ -1202,7 +1202,7 @@ isset_variables:
12021202

12031203
isset_variable:
12041204
variable { zend_do_isset_or_isempty(ZEND_ISSET, &$$, &$1 TSRMLS_CC); }
1205-
| expr_without_variable { zend_error(E_COMPILE_ERROR, "Cannot use isset() on the result of an expression (you can use \"null !== expression\" instead)"); }
1205+
| expr_without_variable { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use isset() on the result of an expression (you can use \"null !== expression\" instead)"); }
12061206
;
12071207

12081208
class_constant:

Zend/zend_multibyte.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static size_t dummy_encoding_converter(unsigned char **to, size_t *to_length, co
5353
static int dummy_encoding_list_parser(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, int persistent TSRMLS_DC)
5454
{
5555
*return_list = pemalloc(0, persistent);
56-
return_size = 0;
56+
*return_size = 0;
5757
return SUCCESS;
5858
}
5959

Zend/zend_opcode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ static void zend_check_finally_breakout(zend_op_array *op_array, zend_uint op_nu
499499
CG(in_compilation) = 1;
500500
CG(active_op_array) = op_array;
501501
CG(zend_lineno) = op_array->opcodes[op_num].lineno;
502-
zend_error(E_COMPILE_ERROR, "jump out of a finally block is disallowed");
502+
zend_error_noreturn(E_COMPILE_ERROR, "jump out of a finally block is disallowed");
503503
}
504504
}
505505
}
@@ -710,7 +710,7 @@ ZEND_API int pass_two(zend_op_array *op_array TSRMLS_DC)
710710
if (op_array->fn_flags & ZEND_ACC_GENERATOR) {
711711
if (opline->op1_type != IS_CONST || Z_TYPE_P(opline->op1.zv) != IS_NULL) {
712712
CG(zend_lineno) = opline->lineno;
713-
zend_error(E_COMPILE_ERROR, "Generators cannot return values using \"return\"");
713+
zend_error_noreturn(E_COMPILE_ERROR, "Generators cannot return values using \"return\"");
714714
}
715715

716716
opline->opcode = ZEND_GENERATOR_RETURN;

ext/bz2/bz2_filter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ static php_stream_filter_status_t php_bz2_decompress_filter(
9797
status = BZ2_bzDecompressInit(streamp, 0, data->small_footprint);
9898

9999
if (BZ_OK != status) {
100+
php_stream_bucket_delref(bucket TSRMLS_CC);
100101
return PSFS_ERR_FATAL;
101102
}
102103

ext/date/php_date.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,7 @@ PHPAPI signed long php_parse_date(char *string, signed long *now)
14061406

14071407
parsed_time = timelib_strtotime(string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
14081408
if (error->error_count) {
1409+
timelib_time_dtor(parsed_time);
14091410
timelib_error_container_dtor(error);
14101411
return -1;
14111412
}

ext/dba/dba.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
625625
char *file_mode;
626626
char mode[4], *pmode, *lock_file_mode = NULL;
627627
int persistent_flag = persistent ? STREAM_OPEN_PERSISTENT : 0;
628-
char *opened_path, *lock_name;
628+
char *opened_path = NULL;
629+
char *lock_name;
629630

630631
if(ac < 2) {
631632
WRONG_PARAM_COUNT;
@@ -848,8 +849,10 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
848849
if (!persistent) {
849850
info->lock.name = opened_path;
850851
} else {
851-
info->lock.name = pestrdup(opened_path, persistent);
852-
efree(opened_path);
852+
if (opened_path) {
853+
info->lock.name = pestrdup(opened_path, persistent);
854+
efree(opened_path);
855+
}
853856
}
854857
}
855858
}

ext/exif/exif.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,14 +2633,15 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
26332633
} else {
26342634
decode = ImageInfo->decode_unicode_le;
26352635
}
2636+
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
26362637
if (zend_multibyte_encoding_converter(
26372638
(unsigned char**)pszInfoPtr,
26382639
&len,
26392640
(unsigned char*)szValuePtr,
26402641
ByteCount,
26412642
zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC),
26422643
zend_multibyte_fetch_encoding(decode TSRMLS_CC)
2643-
TSRMLS_CC) < 0) {
2644+
TSRMLS_CC) == (size_t)-1) {
26442645
len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount);
26452646
}
26462647
return len;
@@ -2653,14 +2654,15 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
26532654
*pszEncoding = estrdup((const char*)szValuePtr);
26542655
szValuePtr = szValuePtr+8;
26552656
ByteCount -= 8;
2657+
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
26562658
if (zend_multibyte_encoding_converter(
26572659
(unsigned char**)pszInfoPtr,
26582660
&len,
26592661
(unsigned char*)szValuePtr,
26602662
ByteCount,
26612663
zend_multibyte_fetch_encoding(ImageInfo->encode_jis TSRMLS_CC),
26622664
zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_jis_be : ImageInfo->decode_jis_le TSRMLS_CC)
2663-
TSRMLS_CC) < 0) {
2665+
TSRMLS_CC) == (size_t)-1) {
26642666
len = exif_process_string_raw(pszInfoPtr, szValuePtr, ByteCount);
26652667
}
26662668
return len;
@@ -2690,16 +2692,16 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
26902692
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
26912693
{
26922694
xp_field->tag = tag;
2693-
2694-
/* Copy the comment */
2695+
2696+
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
26952697
if (zend_multibyte_encoding_converter(
26962698
(unsigned char**)&xp_field->value,
26972699
&xp_field->size,
26982700
(unsigned char*)szValuePtr,
26992701
ByteCount,
27002702
zend_multibyte_fetch_encoding(ImageInfo->encode_unicode TSRMLS_CC),
27012703
zend_multibyte_fetch_encoding(ImageInfo->motorola_intel ? ImageInfo->decode_unicode_be : ImageInfo->decode_unicode_le TSRMLS_CC)
2702-
TSRMLS_CC) < 0) {
2704+
TSRMLS_CC) == (size_t)-1) {
27032705
xp_field->size = exif_process_string_raw(&xp_field->value, szValuePtr, ByteCount);
27042706
}
27052707
return xp_field->size;

ext/exif/tests/bug62523_1.jpg

Lines changed: 9 additions & 0 deletions
Loading

ext/exif/tests/bug62523_1.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug 62523 (php crashes with segfault when exif_read_data called)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded("exif") or die("skip need exif");
6+
?>
7+
--FILE--
8+
<?php
9+
echo "Test\n";
10+
var_dump(count(exif_read_data(__DIR__."/bug62523_1.jpg")));
11+
?>
12+
Done
13+
--EXPECTF--
14+
Test
15+
16+
Warning: exif_read_data(bug62523_1.jpg): File not supported in %sbug62523_1.php on line %d
17+
int(1)
18+
Done

ext/exif/tests/bug62523_2.jpg

504 KB
Loading

ext/exif/tests/bug62523_2.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug 62523 (php crashes with segfault when exif_read_data called)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded("exif") or die("skip need exif");
6+
?>
7+
--FILE--
8+
<?php
9+
echo "Test\n";
10+
var_dump(count(exif_read_data(__DIR__."/bug62523_2.jpg")));
11+
?>
12+
Done
13+
--EXPECT--
14+
Test
15+
int(76)
16+
Done

ext/exif/tests/bug62523_3.jpg

Lines changed: 12 additions & 0 deletions
Loading

ext/exif/tests/bug62523_3.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug 62523 (php crashes with segfault when exif_read_data called)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded("exif") or die("skip need exif");
6+
?>
7+
--FILE--
8+
<?php
9+
echo "Test\n";
10+
var_dump(count(exif_read_data(__DIR__."/bug62523_3.jpg")));
11+
?>
12+
Done
13+
--EXPECTF--
14+
Test
15+
16+
Warning: exif_read_data(bug62523_3.jpg): File not supported in %sbug62523_3.php on line %d
17+
int(1)
18+
Done
7.42 KB
Loading
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
PHP crash when zend_multibyte_encoding_converter returns (size_t)-1)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
$infile = dirname(__FILE__).'/exif_encoding_crash.jpg';
8+
$exif_data = exif_read_data($infile);
9+
echo "*** no core dump ***\n";
10+
?>
11+
===DONE===
12+
--EXPECT--
13+
*** no core dump ***
14+
===DONE===

ext/filter/logical_filters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
714714
if (flags & FILTER_FLAG_NO_RES_RANGE) {
715715
if (
716716
(ip[0] == 0) ||
717-
(ip[0] == 100 && (ip[1] >= 64 || ip[1] <= 127)) ||
717+
(ip[0] == 100 && (ip[1] >= 64 && ip[1] <= 127)) ||
718718
(ip[0] == 128 && ip[1] == 0) ||
719719
(ip[0] == 191 && ip[1] == 255) ||
720720
(ip[0] == 169 && ip[1] == 254) ||

ext/filter/tests/018.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var_dump(filter_var("192.168.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE
1515
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE));
1616
var_dump(filter_var("127.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
1717
var_dump(filter_var("192.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
18-
var_dump(filter_var("100.0.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
18+
var_dump(filter_var("100.64.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
1919
var_dump(filter_var("100.127.255.255", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
2020
var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP));
2121
var_dump(filter_var("256.1237.123.1", FILTER_VALIDATE_IP));

ext/ftp/ftp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ ftp_alloc(ftpbuf_t *ftp, const long size, char **response)
630630
return 0;
631631
}
632632

633-
if (response && ftp->inbuf) {
633+
if (response) {
634634
*response = estrdup(ftp->inbuf);
635635
}
636636

@@ -1638,7 +1638,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
16381638
if (ftp->resp == 226) {
16391639
ftp->data = data_close(ftp, data);
16401640
php_stream_close(tmpstream);
1641-
return ecalloc(1, sizeof(char**));
1641+
return ecalloc(1, sizeof(char*));
16421642
}
16431643

16441644
/* pull data buffer into tmpfile */
@@ -1666,11 +1666,11 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
16661666
}
16671667
}
16681668

1669-
ftp->data = data = data_close(ftp, data);
1669+
ftp->data = data_close(ftp, data);
16701670

16711671
php_stream_rewind(tmpstream);
16721672

1673-
ret = safe_emalloc((lines + 1), sizeof(char**), size * sizeof(char*));
1673+
ret = safe_emalloc((lines + 1), sizeof(char*), size);
16741674

16751675
entry = ret;
16761676
text = (char*) (ret + lines + 1);

ext/gd/php_gd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
PHPAPI extern const char php_sig_gif[3];
6161
PHPAPI extern const char php_sig_jpg[3];
62-
PHPAPI extern const char php_sig_png[3];
62+
PHPAPI extern const char php_sig_png[8];
6363

6464
extern zend_module_entry gd_module_entry;
6565
#define phpext_gd_ptr &gd_module_entry

ext/intl/collator/collator_create.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/* {{{ */
2828
static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
2929
{
30-
char* locale;
30+
const char* locale;
3131
zend_str_size_int locale_len = 0;
3232
zval* object;
3333
Collator_object* co;

ext/intl/dateformat/dateformat_parse.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* tex
6262
}
6363
/* }}} */
6464

65-
static void add_to_localtime_arr( IntlDateFormatter_object *dfo, zval* return_value, UCalendar parsed_calendar, long calendar_field, char* key_name TSRMLS_DC)
65+
static void add_to_localtime_arr( IntlDateFormatter_object *dfo, zval* return_value, const UCalendar *parsed_calendar, long calendar_field, char* key_name TSRMLS_DC)
6666
{
6767
long calendar_field_val = ucal_get( parsed_calendar, calendar_field, &INTL_DATA_ERROR_CODE(dfo));
6868
INTL_METHOD_CHECK_STATUS( dfo, "Date parsing - localtime failed : could not get a field from calendar" );
@@ -83,7 +83,7 @@ static void add_to_localtime_arr( IntlDateFormatter_object *dfo, zval* return_va
8383
*/
8484
static void internal_parse_to_localtime(IntlDateFormatter_object *dfo, char* text_to_parse, int32_t text_len, int32_t *parse_pos, zval *return_value TSRMLS_DC)
8585
{
86-
UCalendar* parsed_calendar = NULL;
86+
UCalendar *parsed_calendar = NULL;
8787
UChar* text_utf16 = NULL;
8888
zend_str_size_int text_utf16_len = 0;
8989
long isInDST = 0;
@@ -92,7 +92,7 @@ static void internal_parse_to_localtime(IntlDateFormatter_object *dfo, char* tex
9292
intl_convert_utf8_to_utf16(&text_utf16, &text_utf16_len, text_to_parse, text_len, &INTL_DATA_ERROR_CODE(dfo));
9393
INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
9494

95-
parsed_calendar = udat_getCalendar(DATE_FORMAT_OBJECT(dfo));
95+
parsed_calendar = (UCalendar *)udat_getCalendar(DATE_FORMAT_OBJECT(dfo));
9696
udat_parseCalendar( DATE_FORMAT_OBJECT(dfo), parsed_calendar, text_utf16, text_utf16_len, parse_pos, &INTL_DATA_ERROR_CODE(dfo));
9797

9898
if (text_utf16) {

0 commit comments

Comments
 (0)