com php-src: Fixed bug #62889: NEWS ext/pdo_mysql/mysql_dri ver.c ext/pdo_mysql/php_pdo_mysql_int.h
| From: | Nikita Popov | Date: | Fri, 11 Dec 2020 10:25:36 +0000 |
| Subject: | com php-src: Fixed bug #62889: NEWS ext/pdo_mysql/mysql_dri ver.c ext/pdo_mysql/php_pdo_mysql_int.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-114411@lists.php.net to get a copy of this message | ||
Commit: 43741a3f26c5094fa818f60744f11139940ccf08
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 11 Dec 2020 11:20:33 +0100
Parents: c927c831e65cdf6aa6152d49820e58e6288a5dcc
Branches: PHP-8.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=43741a3f26c5094fa818f60744f11139940ccf08
Log:
Fixed bug #62889
Our minimum libmysqlclient version requirement is high enough
that we don't need to check for MYSQL_OPT_LOCAL_INFILE support.
However, the mysql_get_option() function seems to only be available
since 5.7 (though it's really hard to find any definitie information
on when MySQL introduced certain functions or changes...) so we
need to store the value of the flag locally to make it available
through getAttribute().
Bugs:
https://bugs.php.net/62889
Changed paths:
M NEWS
M ext/pdo_mysql/mysql_driver.c
M ext/pdo_mysql/php_pdo_mysql_int.h
Diff:
diff --git a/NEWS b/NEWS
index f8d543934fb..ebd59377dde 100644
--- a/NEWS
+++ b/NEWS
@@ -56,6 +56,7 @@ PHP NEWS
missing). (Nikita)
. Fixed bug #72368 (PdoStatement->execute() fails but does not throw an
exception). (Nikita)
+ . Fixed bug #62889 (LOAD DATA INFILE broken). (Nikita)
- Phar:
. Fixed bug #73809 (Phar Zip parse crash - mmap fail). (cmb)
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index 90bc7792d5f..0a0526d9546 100644
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -508,13 +508,11 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval
*return_
case PDO_MYSQL_ATTR_MAX_BUFFER_SIZE:
ZVAL_LONG(return_value, H->max_buffer_size);
break;
-#else
+#endif
+
case PDO_MYSQL_ATTR_LOCAL_INFILE:
- ZVAL_BOOL(
- return_value,
- (H->server->data->options->flags & CLIENT_LOCAL_FILES) == CLIENT_LOCAL_FILES);
+ ZVAL_BOOL(return_value, H->local_infile);
break;
-#endif
default:
PDO_DBG_RETURN(0);
@@ -709,18 +707,15 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
goto cleanup;
}
-#if defined(MYSQL_OPT_LOCAL_INFILE) || defined(PDO_USE_MYSQLND)
- unsigned int local_infile = (unsigned int) pdo_attr_lval(driver_options,
PDO_MYSQL_ATTR_LOCAL_INFILE, 0);
-# ifndef PDO_USE_MYSQLND
- if (PG(open_basedir) && PG(open_basedir)[0] != '\0') {
- local_infile = 0;
- }
-# endif
- if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char *)&local_infile)) {
- pdo_mysql_error(dbh);
- goto cleanup;
- }
+ if (pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0)) {
+ H->local_infile = 1;
+#ifndef PDO_USE_MYSQLND
+ if (PG(open_basedir) && PG(open_basedir)[0] != '\0') {
+ H->local_infile = 0;
+ }
#endif
+ }
+
#ifdef MYSQL_OPT_RECONNECT
/* since 5.0.3, the default for this option is 0 if not specified.
* we want the old behaviour
@@ -824,15 +819,13 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
}
}
#endif
- } else {
-#if defined(MYSQL_OPT_LOCAL_INFILE) || defined(PDO_USE_MYSQLND)
- // in case there are no driver options disable 'local infile' explicitly
- unsigned int local_infile = 0;
- if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char *)&local_infile)) {
- pdo_mysql_error(dbh);
- goto cleanup;
- }
-#endif
+ }
+
+ /* Always explicitly set the LOCAL_INFILE option. */
+ unsigned int local_infile = H->local_infile;
+ if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char *)&local_infile)) {
+ pdo_mysql_error(dbh);
+ goto cleanup;
}
if (vars[0].optval && mysql_options(H->server, MYSQL_SET_CHARSET_NAME, vars[0].optval))
{
diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h
index 7ebf875085c..fe7f149d84f 100644
--- a/ext/pdo_mysql/php_pdo_mysql_int.h
+++ b/ext/pdo_mysql/php_pdo_mysql_int.h
@@ -104,6 +104,7 @@ typedef struct {
unsigned buffered:1;
unsigned emulate_prepare:1;
unsigned fetch_table_names:1;
+ unsigned local_infile:1;
#ifndef PDO_USE_MYSQLND
zend_ulong max_buffer_size;
#endif