Skip to content

Commit 5e152f5

Browse files
committed
Merge branch 'PHP-5.6' of git.php.net:/php-src into PHP-5.6
* 'PHP-5.6' of git.php.net:/php-src: update NEWS Fixed bug #71559 Built-in HTTP server, we can downlaod file in web by bug Check length of string before comparing to :memory: Fix bounds check in strip_tags() Fix test description FIx bug #71569
2 parents 35f6f9b + aa10fc6 commit 5e152f5

File tree

6 files changed

+59
-15
lines changed

6 files changed

+59
-15
lines changed

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #71523 (Copied handle with new option CURLOPT_HTTPHEADER crashes
77
while curl_multi_exec). (Laruence)
88

9+
- CLI server:
10+
. Bug #71559 (Built-in HTTP server, we can download file in web by bug).
11+
(Johannes, Anatol)
12+
913
- Date:
1014
. Fixed bug #68078 (Datetime comparisons ignore microseconds). (Willem-Jan
1115
Zijderveld)
@@ -17,6 +21,9 @@ PHP NEWS
1721
. Fixed bug #62172 (FPM not working with Apache httpd 2.4 balancer/fcgi
1822
setup). (Matt Haught, Remi)
1923

24+
- PDO MySQL:
25+
. Fixed bug #71569 (#70389 fix causes segmentation fault). (Nikita)
26+
2027
- Standard:
2128
. Fixed bug #70720 (strip_tags improper php code parsing). (Julien)
2229

ext/pdo_mysql/mysql_driver.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -658,31 +658,31 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
658658
init_cmd = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_INIT_COMMAND, NULL TSRMLS_CC);
659659
if (init_cmd) {
660660
if (mysql_options(H->server, MYSQL_INIT_COMMAND, (const char *)init_cmd)) {
661-
efree(init_cmd);
661+
str_efree(init_cmd);
662662
pdo_mysql_error(dbh);
663663
goto cleanup;
664664
}
665-
efree(init_cmd);
665+
str_efree(init_cmd);
666666
}
667667
#ifndef PDO_USE_MYSQLND
668668
default_file = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_FILE, NULL TSRMLS_CC);
669669
if (default_file) {
670670
if (mysql_options(H->server, MYSQL_READ_DEFAULT_FILE, (const char *)default_file)) {
671-
efree(default_file);
671+
str_efree(default_file);
672672
pdo_mysql_error(dbh);
673673
goto cleanup;
674674
}
675-
efree(default_file);
675+
str_efree(default_file);
676676
}
677677

678678
default_group= pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_GROUP, NULL TSRMLS_CC);
679679
if (default_group) {
680680
if (mysql_options(H->server, MYSQL_READ_DEFAULT_GROUP, (const char *)default_group)) {
681-
efree(default_group);
681+
str_efree(default_group);
682682
pdo_mysql_error(dbh);
683683
goto cleanup;
684684
}
685-
efree(default_group);
685+
str_efree(default_group);
686686
}
687687
#endif
688688
compress = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_COMPRESS, 0 TSRMLS_CC);
@@ -702,19 +702,19 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
702702
if (ssl_key || ssl_cert || ssl_ca || ssl_capath || ssl_cipher) {
703703
mysql_ssl_set(H->server, ssl_key, ssl_cert, ssl_ca, ssl_capath, ssl_cipher);
704704
if (ssl_key) {
705-
efree(ssl_key);
705+
str_efree(ssl_key);
706706
}
707707
if (ssl_cert) {
708-
efree(ssl_cert);
708+
str_efree(ssl_cert);
709709
}
710710
if (ssl_ca) {
711-
efree(ssl_ca);
711+
str_efree(ssl_ca);
712712
}
713713
if (ssl_capath) {
714-
efree(ssl_capath);
714+
str_efree(ssl_capath);
715715
}
716716
if (ssl_cipher) {
717-
efree(ssl_cipher);
717+
str_efree(ssl_cipher);
718718
}
719719
}
720720

@@ -724,10 +724,10 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
724724
if (public_key) {
725725
if (mysql_options(H->server, MYSQL_SERVER_PUBLIC_KEY, public_key)) {
726726
pdo_mysql_error(dbh);
727-
efree(public_key);
727+
str_efree(public_key);
728728
goto cleanup;
729729
}
730-
efree(public_key);
730+
str_efree(public_key);
731731
}
732732
}
733733
#endif

ext/pdo_mysql/tests/bug71569.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug #71569 (#70389 fix causes segmentation fault)
3+
--SKIPIF--
4+
<?php
5+
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
6+
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
MySQLPDOTest::skip();
8+
?>
9+
--FILE--
10+
<?php
11+
require(dirname(__FILE__). DIRECTORY_SEPARATOR . 'config.inc');
12+
13+
try {
14+
new PDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [
15+
PDO::MYSQL_ATTR_INIT_COMMAND => null,
16+
]);
17+
} catch (PDOException $e) {
18+
echo $e->getMessage();
19+
}
20+
21+
?>
22+
--EXPECT--
23+
SQLSTATE[42000] [1065] Query was empty

ext/sqlite3/sqlite3.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ PHP_METHOD(sqlite3, open)
123123
if (strlen(filename) != filename_len) {
124124
return;
125125
}
126-
if (memcmp(filename, ":memory:", sizeof(":memory:")) != 0) {
126+
if (filename_len != sizeof(":memory:")-1 ||
127+
memcmp(filename, ":memory:", sizeof(":memory:")-1) != 0) {
127128
if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
128129
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to expand filepath", 0 TSRMLS_CC);
129130
return;

ext/standard/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4822,7 +4822,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
48224822
* state == 2 (PHP). Switch back to HTML.
48234823
*/
48244824

4825-
if (state == 2 && p > buf+2 && strncasecmp(p-4, "<?xm", 4) == 0) {
4825+
if (state == 2 && p > buf+4 && strncasecmp(p-4, "<?xm", 4) == 0) {
48264826
state = 1; is_xml=1;
48274827
break;
48284828
}

sapi/cli/php_cli_server.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,19 @@ static int php_cli_server_begin_send_static(php_cli_server *server, php_cli_serv
20582058
return php_cli_server_send_error_page(server, client, 400 TSRMLS_CC);
20592059
}
20602060

2061+
#ifdef PHP_WIN32
2062+
/* The win32 namespace will cut off trailing dots and spaces. Since the
2063+
VCWD functionality isn't used here, a sophisticated functionality
2064+
would have to be reimplemented to know ahead there are no files
2065+
with invalid names there. The simplest is just to forbid invalid
2066+
filenames, which is done here. */
2067+
if (client->request.path_translated &&
2068+
('.' == client->request.path_translated[client->request.path_translated_len-1] ||
2069+
' ' == client->request.path_translated[client->request.path_translated_len-1])) {
2070+
return php_cli_server_send_error_page(server, client, 500);
2071+
}
2072+
#endif
2073+
20612074
fd = client->request.path_translated ? open(client->request.path_translated, O_RDONLY): -1;
20622075
if (fd < 0) {
20632076
return php_cli_server_send_error_page(server, client, 404 TSRMLS_CC);

0 commit comments

Comments
 (0)