From da011a312a6c6cd7ff12fe1aa0de1e33fba2f167 Mon Sep 17 00:00:00 2001 From: Darek Slusarczyk Date: Mon, 22 Feb 2021 11:03:24 +0100 Subject: Fix #80329: Add option to specify LOAD DATA LOCAL white list folder * allow the user to specify a folder where files that can be sent via LOAD DATA LOCAL can exist * add mysqli.local_infile_directory for mysqli (ignored if mysqli.allow_local_infile is enabled) * add PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY for pdo_mysql (ignored if PDO::MYSQL_ATTR_LOCAL_INFILE is enabled) * add related tests * fixes for building with libmysql 8.x * small improvement in existing tests * update php.ini-[development|production] files Closes GH-6448. Co-authored-by: Nikita Popov --- ext/mysqlnd/mysqlnd_connection.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ext/mysqlnd/mysqlnd_connection.c') diff --git a/ext/mysqlnd/mysqlnd_connection.c b/ext/mysqlnd/mysqlnd_connection.c index 168e161d1b..8730de04b1 100644 --- a/ext/mysqlnd/mysqlnd_connection.c +++ b/ext/mysqlnd/mysqlnd_connection.c @@ -251,6 +251,10 @@ MYSQLND_METHOD(mysqlnd_conn_data, free_options)(MYSQLND_CONN_DATA * conn) mnd_pefree(conn->options->connect_attr, pers); conn->options->connect_attr = NULL; } + if (conn->options->local_infile_directory) { + mnd_pefree(conn->options->local_infile_directory, pers); + conn->options->local_infile_directory = NULL; + } } /* }}} */ @@ -1648,6 +1652,19 @@ MYSQLND_METHOD(mysqlnd_conn_data, set_client_option)(MYSQLND_CONN_DATA * const c conn->options->flags &= ~CLIENT_LOCAL_FILES; } break; + case MYSQL_OPT_LOAD_DATA_LOCAL_DIR: + { + if (conn->options->local_infile_directory) { + mnd_pefree(conn->options->local_infile_directory, conn->persistent); + } + + if (!value || (*value == '\0')) { + conn->options->local_infile_directory = NULL; + } else { + conn->options->local_infile_directory = mnd_pestrdup(value, conn->persistent); + } + break; + } case MYSQL_INIT_COMMAND: { char ** new_init_commands; -- cgit v1.2.1