iliaa Thu Dec 20 00:31:49 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/mysql php_mysql.c
/php-src NEWS
Log:
MFB: Fixed bug #43635 (mysql extension ingores INI settings on NULL values
passed to mysql_connect())
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/php_mysql.c?r1=1.213.2.6.2.17&r2=1.213.2.6.2.18&diff_format=u
Index: php-src/ext/mysql/php_mysql.c
diff -u php-src/ext/mysql/php_mysql.c:1.213.2.6.2.17
php-src/ext/mysql/php_mysql.c:1.213.2.6.2.18
--- php-src/ext/mysql/php_mysql.c:1.213.2.6.2.17 Mon Oct 8 18:25:52 2007
+++ php-src/ext/mysql/php_mysql.c Thu Dec 20 00:31:49 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mysql.c,v 1.213.2.6.2.17 2007/10/08 18:25:52 andrey Exp $ */
+/* $Id: php_mysql.c,v 1.213.2.6.2.18 2007/12/20 00:31:49 iliaa Exp $ */
/* TODO:
*
@@ -514,6 +514,7 @@
static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
char *user=NULL, *passwd=NULL, *host_and_port=NULL, *socket=NULL,
*tmp=NULL, *host=NULL;
+ int user_len, passwd_len, host_len;
char *hashed_details=NULL;
int hashed_details_length, port = MYSQL_PORT;
int client_flags = 0;
@@ -521,7 +522,6 @@
#if MYSQL_VERSION_ID <= 32230
void (*handler) (int);
#endif
- zval **z_host=NULL, **z_user=NULL, **z_passwd=NULL, **z_new_link=NULL,
**z_client_flags=NULL;
zend_bool free_host=0, new_link=0;
long connect_timeout;
@@ -556,99 +556,32 @@
hashed_details_length = spprintf(&hashed_details, 0,
"mysql__%s_", user);
client_flags = CLIENT_INTERACTIVE;
} else {
- host_and_port = MySG(default_host);
- user = MySG(default_user);
- passwd = MySG(default_password);
-
- switch(ZEND_NUM_ARGS()) {
- case 0: /* defaults */
- break;
- case 1: {
- if (zend_get_parameters_ex(1,
&z_host)==FAILURE) {
- MYSQL_DO_CONNECT_RETURN_FALSE();
- }
- }
- break;
- case 2: {
- if (zend_get_parameters_ex(2, &z_host,
&z_user)==FAILURE) {
- MYSQL_DO_CONNECT_RETURN_FALSE();
- }
- convert_to_string_ex(z_user);
- user = Z_STRVAL_PP(z_user);
- }
- break;
- case 3: {
- if (zend_get_parameters_ex(3, &z_host,
&z_user, &z_passwd) == FAILURE) {
- MYSQL_DO_CONNECT_RETURN_FALSE();
- }
- convert_to_string_ex(z_user);
- convert_to_string_ex(z_passwd);
- user = Z_STRVAL_PP(z_user);
- passwd = Z_STRVAL_PP(z_passwd);
- }
- break;
- case 4: {
- if (!persistent) {
- if (zend_get_parameters_ex(4,
&z_host, &z_user, &z_passwd, &z_new_link) == FAILURE) {
-
MYSQL_DO_CONNECT_RETURN_FALSE();
- }
- convert_to_string_ex(z_user);
- convert_to_string_ex(z_passwd);
-
convert_to_boolean_ex(z_new_link);
- user = Z_STRVAL_PP(z_user);
- passwd = Z_STRVAL_PP(z_passwd);
- new_link =
Z_BVAL_PP(z_new_link);
- }
- else {
- if (zend_get_parameters_ex(4,
&z_host, &z_user, &z_passwd, &z_client_flags) == FAILURE) {
-
MYSQL_DO_CONNECT_RETURN_FALSE();
- }
- convert_to_string_ex(z_user);
- convert_to_string_ex(z_passwd);
-
convert_to_long_ex(z_client_flags);
- user = Z_STRVAL_PP(z_user);
- passwd = Z_STRVAL_PP(z_passwd);
- client_flags =
Z_LVAL_PP(z_client_flags);
- }
- }
- break;
- case 5: {
- if (zend_get_parameters_ex(5, &z_host,
&z_user, &z_passwd, &z_new_link, &z_client_flags) == FAILURE) {
- MYSQL_DO_CONNECT_RETURN_FALSE();
- }
- convert_to_string_ex(z_user);
- convert_to_string_ex(z_passwd);
- convert_to_boolean_ex(z_new_link);
- convert_to_long_ex(z_client_flags);
- user = Z_STRVAL_PP(z_user);
- passwd = Z_STRVAL_PP(z_passwd);
- new_link = Z_BVAL_PP(z_new_link);
- client_flags =
Z_LVAL_PP(z_client_flags);
- }
- break;
- default:
- WRONG_PARAM_COUNT;
- break;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"|s!s!s!ll", &host_and_port, &host_len,
+ &user,
&user_len, &passwd, &passwd_len,
+
&new_link, &client_flags)==FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ if (!host_and_port) {
+ host_and_port = MySG(default_host);
+ }
+ if (!user) {
+ user = MySG(default_user);
}
+ if (!passwd) {
+ passwd = MySG(default_password);
+ }
+
+ /* mysql_pconnect does not support new_link parameter */
+ if (persistent) {
+ client_flags= new_link;
+ }
+
/* disable local infile option for open_basedir */
if (((PG(open_basedir) && PG(open_basedir)[0] != '\0') ||
PG(safe_mode)) && (client_flags & CLIENT_LOCAL_FILES)) {
client_flags ^= CLIENT_LOCAL_FILES;
}
- if (z_host) {
- SEPARATE_ZVAL(z_host); /* We may modify z_host if it
contains a port, separate */
- convert_to_string_ex(z_host);
- host_and_port = Z_STRVAL_PP(z_host);
- if (z_user) {
- convert_to_string_ex(z_user);
- user = Z_STRVAL_PP(z_user);
- if (z_passwd) {
- convert_to_string_ex(z_passwd);
- passwd = Z_STRVAL_PP(z_passwd);
- }
- }
- }
-
hashed_details_length = spprintf(&hashed_details, 0,
"mysql_%s_%s_%s_%d", SAFE_STRING(host_and_port), SAFE_STRING(user),
SAFE_STRING(passwd), client_flags);
}
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1036&r2=1.2027.2.547.2.1037&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1036 php-src/NEWS:1.2027.2.547.2.1037
--- php-src/NEWS:1.2027.2.547.2.1036 Tue Dec 18 13:47:37 2007
+++ php-src/NEWS Thu Dec 20 00:31:49 2007
@@ -3,6 +3,8 @@
?? ??? 2008, PHP 5.2.6
- Fixed weired behavior in CGI parameter parsing. (Dmitry, Hannes Magnusson)
+- Fixed bug #43635 (mysql extension ingores INI settings on NULL values
+ passed to mysql_connect()). (Ilia)
- Fixed bug #43620 (Workaround for a bug inside libcurl 7.16.2 that can result
in a crash). (Ilia)
- Fixed bug #43606 (define missing depencies of the exif extension).
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php