Skip to content

Commit 9789df7

Browse files
author
Yasuo Ohgaki
committed
Merge branch 'PHP-5.4' of git.php.net:php-src into PHP-5.4
* 'PHP-5.4' of git.php.net:php-src: bump version Update NEWS fix bug #65481 (shutdown segfault due to serialize) Track created curl_slist structs by option so they can be updated in situ. Fixed bug #64503 (Compilation fails with error: conflicting types for 'zendparse'). added new glob() test fix using wrong buffer pointer Fix bug #65470 Segmentation fault in zend_error() with --enable-dtrace Fix for php bug #64802 includes test case new for fix #65225 Fixed #65225: PHP_BINARY incorrectly set Use pkg-config to detect iodbc Add -P option to use the current binary Create test to the extension xmlrpc Fixbug: phpize --clean will delete include/*.h
2 parents cb539b3 + d487f5e commit 9789df7

22 files changed

+529
-120
lines changed

NEWS

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3-
?? ??? 2013, PHP 5.4.19
3+
?? ??? 2013, PHP 5.4.20
44

55
- Core:
6+
. Fixed bug #65481 (shutdown segfault due to serialize) (Mike)
7+
. Fixed bug #65470 (Segmentation fault in zend_error() with
8+
--enable-dtrace). (Chris Jones, Kris Van Hees)
69
. Fixed bug #65372 (Segfault in gc_zval_possible_root when return reference
710
fails). (Laruence)
811
. Fixed bug #65304 (Use of max int in array_sum). (Laruence)
912
. Fixed bug #65291 (get_defined_constants() causes PHP to crash in a very
1013
limited case). (Arpad)
14+
. Fixed bug #65225 (PHP_BINARY incorrectly set). (Patrick Allaert)
1115
. Improved fix for bug #63186 (compile failure on netbsd). (Matteo)
1216
. Fixed bug #62692 (PHP fails to build with DTrace). (Chris Jones, Kris Van Hees)
1317
. Fixed bug #61345 (CGI mode - make install don't work). (Michael Heimpold)
@@ -16,6 +20,13 @@ PHP NEWS
1620
. Fixed bug #61268 (--enable-dtrace leads make to clobber
1721
Zend/zend_dtrace.d) (Chris Jones)
1822

23+
- cURL:
24+
. Fixed bug #65458 (curl memory leak). (Adam)
25+
26+
- Openssl:
27+
. Fixed bug #64802 (openssl_x509_parse fails to parse subject properly in
28+
some cases). (Mark Jones)
29+
1930
- Session:
2031
. Fixed bug #62129 (rfc1867 crashes php even though turned off). (gxd305 at
2132
gmail dot com)
@@ -45,7 +56,16 @@ PHP NEWS
4556
. Fixed bug #65391 (Unable to send vary header user-agent when
4657
ob_start('ob_gzhandler') is called) (Mike)
4758

48-
?? ??? 2013, PHP 5.4.18
59+
22 Aug 2013, PHP 5.4.19
60+
61+
- Core:
62+
. Fixed bug #64503 (Compilation fails with error: conflicting types for
63+
'zendparse'). (Laruence)
64+
65+
- Openssl:
66+
. Fixed UMR in fix for CVE-2013-4248.
67+
68+
15 Aug 2013, PHP 5.4.18
4969

5070
- Core:
5171
. Fixed value of FILTER_SANITIZE_FULL_SPECIAL_CHARS constant (previously was

Zend/zend.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,17 +1091,19 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
10911091
error_filename = "Unknown";
10921092
}
10931093

1094-
va_start(args, format);
1095-
10961094
#ifdef HAVE_DTRACE
10971095
if(DTRACE_ERROR_ENABLED()) {
10981096
char *dtrace_error_buffer;
1097+
va_start(args, format);
10991098
zend_vspprintf(&dtrace_error_buffer, 0, format, args);
11001099
DTRACE_ERROR(dtrace_error_buffer, (char *)error_filename, error_lineno);
11011100
efree(dtrace_error_buffer);
1101+
va_end(args);
11021102
}
11031103
#endif /* HAVE_DTRACE */
11041104

1105+
va_start(args, format);
1106+
11051107
/* if we don't have a user defined error handler */
11061108
if (!EG(user_error_handler)
11071109
|| !(EG(user_error_handler_error_reporting) & type)

Zend/zend_language_parser.y

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,19 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
4141

4242
#define YYERROR_VERBOSE
4343
#define YYSTYPE znode
44-
#ifdef ZTS
45-
# define YYPARSE_PARAM tsrm_ls
46-
# define YYLEX_PARAM tsrm_ls
47-
#endif
48-
4944

5045
%}
5146

5247
%pure_parser
5348
%expect 3
5449

50+
%code requires {
51+
#ifdef ZTS
52+
# define YYPARSE_PARAM tsrm_ls
53+
# define YYLEX_PARAM tsrm_ls
54+
#endif
55+
}
56+
5557
%token END 0 "end of file"
5658
%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
5759
%token T_INCLUDE "include (T_INCLUDE)"

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
119119

120120
PHP_MAJOR_VERSION=5
121121
PHP_MINOR_VERSION=4
122-
PHP_RELEASE_VERSION=19
122+
PHP_RELEASE_VERSION=20
123123
PHP_EXTRA_VERSION="-dev"
124124
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
125125
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`

ext/curl/interface.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,9 +1373,9 @@ static void curl_free_post(void **post)
13731373

13741374
/* {{{ curl_free_slist
13751375
*/
1376-
static void curl_free_slist(void **slist)
1376+
static void curl_free_slist(void *slist)
13771377
{
1378-
curl_slist_free_all((struct curl_slist *) *slist);
1378+
curl_slist_free_all(*((struct curl_slist **) slist));
13791379
}
13801380
/* }}} */
13811381

@@ -1443,8 +1443,10 @@ static void alloc_curl_handle(php_curl **ch)
14431443
(*ch)->handlers->read->stream = NULL;
14441444

14451445
zend_llist_init(&(*ch)->to_free->str, sizeof(char *), (llist_dtor_func_t) curl_free_string, 0);
1446-
zend_llist_init(&(*ch)->to_free->slist, sizeof(struct curl_slist), (llist_dtor_func_t) curl_free_slist, 0);
14471446
zend_llist_init(&(*ch)->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_post, 0);
1447+
1448+
(*ch)->to_free->slist = emalloc(sizeof(HashTable));
1449+
zend_hash_init((*ch)->to_free->slist, 4, NULL, curl_free_slist, 0);
14481450
}
14491451
/* }}} */
14501452

@@ -1675,6 +1677,7 @@ PHP_FUNCTION(curl_copy_handle)
16751677
curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch);
16761678
curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch);
16771679

1680+
efree(dupch->to_free->slist);
16781681
efree(dupch->to_free);
16791682
dupch->to_free = ch->to_free;
16801683

@@ -2184,7 +2187,7 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu
21842187
return 1;
21852188
}
21862189
}
2187-
zend_llist_add_element(&ch->to_free->slist, &slist);
2190+
zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NULL);
21882191

21892192
error = curl_easy_setopt(ch->cp, option, slist);
21902193

@@ -2680,8 +2683,9 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC)
26802683
/* cURL destructors should be invoked only by last curl handle */
26812684
if (Z_REFCOUNT_P(ch->clone) <= 1) {
26822685
zend_llist_clean(&ch->to_free->str);
2683-
zend_llist_clean(&ch->to_free->slist);
26842686
zend_llist_clean(&ch->to_free->post);
2687+
zend_hash_destroy(ch->to_free->slist);
2688+
efree(ch->to_free->slist);
26852689
efree(ch->to_free);
26862690
FREE_ZVAL(ch->clone);
26872691
} else {

ext/curl/php_curl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct _php_curl_send_headers {
126126
struct _php_curl_free {
127127
zend_llist str;
128128
zend_llist post;
129-
zend_llist slist;
129+
HashTable *slist;
130130
};
131131

132132
typedef struct {

ext/curl/tests/bug65458.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug #65458 (curl memory leak)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('curl')) exit("skip curl extension not loaded");
6+
?>
7+
--FILE--
8+
<?php
9+
$ch = curl_init();
10+
$init = memory_get_usage();
11+
for ($i = 0; $i < 10000; $i++) {
12+
curl_setopt($ch, CURLOPT_HTTPHEADER, [ "SOAPAction: getItems" ]);
13+
}
14+
15+
$preclose = memory_get_usage();
16+
curl_close($ch);
17+
18+
// This is a slightly tricky heuristic, but basically, we want to ensure
19+
// $preclose - $init has a delta in the order of bytes, not megabytes. Given
20+
// the number of iterations in the loop, if we're wasting memory here, we
21+
// should have megs and megs of extra allocations.
22+
var_dump(($preclose - $init) < 10000);
23+
?>
24+
--EXPECT--
25+
bool(true)

ext/odbc/config.m4

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -370,18 +370,33 @@ PHP_ARG_WITH(iodbc,,
370370

371371
if test "$PHP_IODBC" != "no"; then
372372
AC_MSG_CHECKING(for iODBC support)
373-
if test "$PHP_IODBC" = "yes"; then
374-
PHP_IODBC=/usr/local
373+
if test -z "$PKG_CONFIG"; then
374+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
375+
fi
376+
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libiodbc ; then
377+
PHP_ADD_LIBRARY_WITH_PATH(iodbc, $PHP_IODBC/$PHP_LIBDIR)
378+
ODBC_TYPE=iodbc
379+
ODBC_INCLUDE=`$PKG_CONFIG --cflags-only-I libiodbc`
380+
ODBC_LFLAGS=`$PKG_CONFIG --libs-only-L libiodbc`
381+
ODBC_LIBS=`$PKG_CONFIG --libs-only-l libiodbc`
382+
PHP_EVAL_INCLINE($ODBC_INCLUDE)
383+
AC_DEFINE(HAVE_IODBC,1,[ ])
384+
AC_DEFINE(HAVE_ODBC2,1,[ ])
385+
AC_MSG_RESULT([$ext_output])
386+
else
387+
if test "$PHP_IODBC" = "yes"; then
388+
PHP_IODBC=/usr/local
389+
fi
390+
PHP_ADD_LIBRARY_WITH_PATH(iodbc, $PHP_IODBC/$PHP_LIBDIR)
391+
PHP_ADD_INCLUDE($PHP_IODBC/include, 1)
392+
ODBC_TYPE=iodbc
393+
ODBC_INCLUDE=-I$PHP_IODBC/include
394+
ODBC_LFLAGS=-L$PHP_IODBC/$PHP_LIBDIR
395+
ODBC_LIBS=-liodbc
396+
AC_DEFINE(HAVE_IODBC,1,[ ])
397+
AC_DEFINE(HAVE_ODBC2,1,[ ])
398+
AC_MSG_RESULT([$ext_output])
375399
fi
376-
PHP_ADD_LIBRARY_WITH_PATH(iodbc, $PHP_IODBC/$PHP_LIBDIR)
377-
PHP_ADD_INCLUDE($PHP_IODBC/include, 1)
378-
ODBC_TYPE=iodbc
379-
ODBC_INCLUDE=-I$PHP_IODBC/include
380-
ODBC_LFLAGS=-L$PHP_IODBC/$PHP_LIBDIR
381-
ODBC_LIBS=-liodbc
382-
AC_DEFINE(HAVE_IODBC,1,[ ])
383-
AC_DEFINE(HAVE_ODBC2,1,[ ])
384-
AC_MSG_RESULT([$ext_output])
385400
fi
386401
fi
387402

ext/openssl/openssl.c

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req
561561

562562
static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int shortname TSRMLS_DC) /* {{{ */
563563
{
564+
zval **data;
564565
zval *subitem, *subentries;
565566
int i, j = -1, last = -1, obj_cnt = 0;
566567
char *sname;
@@ -592,39 +593,27 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int s
592593
sname = (char *) OBJ_nid2ln(nid);
593594
}
594595

595-
MAKE_STD_ZVAL(subentries);
596-
array_init(subentries);
596+
str = X509_NAME_ENTRY_get_data(ne);
597+
if (ASN1_STRING_type(str) != V_ASN1_UTF8STRING) {
598+
to_add_len = ASN1_STRING_to_UTF8(&to_add, str);
599+
} else {
600+
to_add = ASN1_STRING_data(str);
601+
to_add_len = ASN1_STRING_length(str);
602+
}
597603

598-
last = -1;
599-
for (;;) {
600-
j = X509_NAME_get_index_by_OBJ(name, obj, last);
601-
if (j < 0) {
602-
if (last != -1) break;
603-
} else {
604-
obj_cnt++;
605-
ne = X509_NAME_get_entry(name, j);
606-
str = X509_NAME_ENTRY_get_data(ne);
607-
if (ASN1_STRING_type(str) != V_ASN1_UTF8STRING) {
608-
to_add_len = ASN1_STRING_to_UTF8(&to_add, str);
609-
if (to_add_len != -1) {
610-
add_next_index_stringl(subentries, (char *)to_add, to_add_len, 1);
611-
}
612-
} else {
613-
to_add = ASN1_STRING_data(str);
614-
to_add_len = ASN1_STRING_length(str);
604+
if (to_add_len != -1) {
605+
if (zend_hash_find(Z_ARRVAL_P(subitem), sname, strlen(sname)+1, (void**)&data) == SUCCESS) {
606+
if (Z_TYPE_PP(data) == IS_ARRAY) {
607+
subentries = *data;
608+
add_next_index_stringl(subentries, (char *)to_add, to_add_len, 1);
609+
} else if (Z_TYPE_PP(data) == IS_STRING) {
610+
MAKE_STD_ZVAL(subentries);
611+
array_init(subentries);
612+
add_next_index_stringl(subentries, Z_STRVAL_PP(data), Z_STRLEN_PP(data), 1);
615613
add_next_index_stringl(subentries, (char *)to_add, to_add_len, 1);
614+
zend_hash_update(Z_ARRVAL_P(subitem), sname, strlen(sname)+1, &subentries, sizeof(zval*), NULL);
616615
}
617-
}
618-
last = j;
619-
}
620-
i = last;
621-
622-
if (obj_cnt > 1) {
623-
add_assoc_zval_ex(subitem, sname, strlen(sname) + 1, subentries);
624-
} else {
625-
zval_dtor(subentries);
626-
FREE_ZVAL(subentries);
627-
if (obj_cnt && str && to_add_len > -1) {
616+
} else {
628617
add_assoc_stringl(subitem, sname, (char *)to_add, to_add_len, 1);
629618
}
630619
}
@@ -1574,6 +1563,7 @@ PHP_FUNCTION(openssl_x509_parse)
15741563
bio_out = BIO_new(BIO_s_mem());
15751564
if (nid == NID_subject_alt_name) {
15761565
if (openssl_x509v3_subjectAltName(bio_out, extension) == 0) {
1566+
BIO_get_mem_ptr(bio_out, &bio_buf);
15771567
add_assoc_stringl(subitem, extname, bio_buf->data, bio_buf->length, 1);
15781568
} else {
15791569
zval_dtor(return_value);

ext/openssl/tests/bug64802.pem

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIGfzCCBWegAwIBAgIQSVCinGH6MkvjJZjRyjK9nTANBgkqhkiG9w0BAQUFADCB
3+
jjELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G
4+
A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxNDAyBgNV
5+
BAMTK0NPTU9ETyBFeHRlbmRlZCBWYWxpZGF0aW9uIFNlY3VyZSBTZXJ2ZXIgQ0Ew
6+
HhcNMTIwMjI5MDAwMDAwWhcNMTQwMjI4MjM1OTU5WjCCAW8xEjAQBgNVBAMTCXd3
7+
dy5yZC5pbzERMA8GA1UEAxMIcmRpby5jb20xDjAMBgNVBAMTBXJkLmlvMRUwEwYD
8+
VQQDEwxhcGkucmRpby5jb20xEjAQBgNVBAMTCWFwaS5yZC5pbzEQMA4GA1UEBRMH
9+
NDU4NjAwNzETMBEGCysGAQQBgjc8AgEDEwJVUzEZMBcGCysGAQQBgjc8AgECEwhE
10+
ZWxhd2FyZTEdMBsGA1UEDxMUUHJpdmF0ZSBPcmdhbml6YXRpb24xCzAJBgNVBAYT
11+
AlVTMQ4wDAYDVQQREwU5NDEwMzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDVNhbiBG
12+
cmFuY2lzY28xFzAVBgNVBAkTDjE1NTAgQnJ5YW50IHN0MRMwEQYDVQQKEwpSZGlv
13+
LCBJbmMuMSMwIQYDVQQLExpDT01PRE8gRVYgTXVs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