You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
auto_local_infile is not an user-settable option
it's an internal state variable, should be in st_mariadb_extension. In particular, treating it like an option, caused mysql->options to be allocated in mysql_init(), which caused failed reconnects to leak memory: Direct leak of 10824 byte(s) in 33 object(s) allocated from: #0 0x7f00db5ba79a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a) #1 0x55eb1b1d545e in mysql_init /home/buildbot/mariadb-10.2-build24320/libmariadb/libmariadb/mariadb_lib.c:1021 #2 0x55eb1b1e342e in mariadb_reconnect /home/buildbot/mariadb-10.2-build24320/libmariadb/libmariadb/mariadb_lib.c:1621 ...
This commit is contained in:
@@ -78,7 +78,6 @@ struct st_mysql_options_extension {
|
|||||||
char *server_public_key;
|
char *server_public_key;
|
||||||
char *proxy_header;
|
char *proxy_header;
|
||||||
size_t proxy_header_len;
|
size_t proxy_header_len;
|
||||||
my_bool auto_local_infile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct st_connection_handler
|
typedef struct st_connection_handler
|
||||||
@@ -104,6 +103,7 @@ struct st_mariadb_extension {
|
|||||||
struct st_mariadb_session_state session_state[SESSION_TRACK_TYPES];
|
struct st_mariadb_session_state session_state[SESSION_TRACK_TYPES];
|
||||||
unsigned long mariadb_client_flag; /* MariaDB specific client flags */
|
unsigned long mariadb_client_flag; /* MariaDB specific client flags */
|
||||||
unsigned long mariadb_server_capabilities; /* MariaDB specific server capabilities */
|
unsigned long mariadb_server_capabilities; /* MariaDB specific server capabilities */
|
||||||
|
my_bool auto_local_infile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define OPT_EXT_VAL(a,key) \
|
#define OPT_EXT_VAL(a,key) \
|
||||||
|
@@ -430,12 +430,12 @@ ma_simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg
|
|||||||
size_t length, my_bool skipp_check, void *opt_arg)
|
size_t length, my_bool skipp_check, void *opt_arg)
|
||||||
{
|
{
|
||||||
if ((mysql->options.client_flag & CLIENT_LOCAL_FILES) &&
|
if ((mysql->options.client_flag & CLIENT_LOCAL_FILES) &&
|
||||||
mysql->options.extension && mysql->options.extension->auto_local_infile == WAIT_FOR_QUERY &&
|
mysql->options.extension && mysql->extension->auto_local_infile == WAIT_FOR_QUERY &&
|
||||||
arg && (*arg == 'l' || *arg == 'L') &&
|
arg && (*arg == 'l' || *arg == 'L') &&
|
||||||
command == COM_QUERY)
|
command == COM_QUERY)
|
||||||
{
|
{
|
||||||
if (strncasecmp(arg, "load", 4) == 0)
|
if (strncasecmp(arg, "load", 4) == 0)
|
||||||
mysql->options.extension->auto_local_infile= ACCEPT_FILE_REQUEST;
|
mysql->extension->auto_local_infile= ACCEPT_FILE_REQUEST;
|
||||||
}
|
}
|
||||||
return mysql->methods->db_command(mysql, command, arg, length, skipp_check, opt_arg);
|
return mysql->methods->db_command(mysql, command, arg, length, skipp_check, opt_arg);
|
||||||
}
|
}
|
||||||
@@ -1018,8 +1018,8 @@ mysql_init(MYSQL *mysql)
|
|||||||
|
|
||||||
if (ENABLED_LOCAL_INFILE != LOCAL_INFILE_MODE_OFF)
|
if (ENABLED_LOCAL_INFILE != LOCAL_INFILE_MODE_OFF)
|
||||||
mysql->options.client_flag|= CLIENT_LOCAL_FILES;
|
mysql->options.client_flag|= CLIENT_LOCAL_FILES;
|
||||||
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, auto_local_infile, ENABLED_LOCAL_INFILE == LOCAL_INFILE_MODE_AUTO
|
mysql->extension->auto_local_infile= ENABLED_LOCAL_INFILE == LOCAL_INFILE_MODE_AUTO
|
||||||
? WAIT_FOR_QUERY : ALWAYS_ACCEPT);
|
? WAIT_FOR_QUERY : ALWAYS_ACCEPT;
|
||||||
mysql->options.reconnect= 0;
|
mysql->options.reconnect= 0;
|
||||||
return mysql;
|
return mysql;
|
||||||
error:
|
error:
|
||||||
@@ -2123,10 +2123,10 @@ int mthd_my_read_query_result(MYSQL *mysql)
|
|||||||
ulong field_count;
|
ulong field_count;
|
||||||
MYSQL_DATA *fields;
|
MYSQL_DATA *fields;
|
||||||
ulong length;
|
ulong length;
|
||||||
my_bool can_local_infile= (mysql->options.extension) && (mysql->options.extension->auto_local_infile != WAIT_FOR_QUERY);
|
my_bool can_local_infile= (mysql->options.extension) && (mysql->extension->auto_local_infile != WAIT_FOR_QUERY);
|
||||||
|
|
||||||
if (mysql->options.extension && mysql->options.extension->auto_local_infile == ACCEPT_FILE_REQUEST)
|
if (mysql->options.extension && mysql->extension->auto_local_infile == ACCEPT_FILE_REQUEST)
|
||||||
mysql->options.extension->auto_local_infile= WAIT_FOR_QUERY;
|
mysql->extension->auto_local_infile= WAIT_FOR_QUERY;
|
||||||
|
|
||||||
if (!mysql || (length = ma_net_safe_read(mysql)) == packet_error)
|
if (!mysql || (length = ma_net_safe_read(mysql)) == packet_error)
|
||||||
{
|
{
|
||||||
@@ -2685,8 +2685,8 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
|
|||||||
mysql->options.client_flag&= ~CLIENT_LOCAL_FILES;
|
mysql->options.client_flag&= ~CLIENT_LOCAL_FILES;
|
||||||
if (arg1) {
|
if (arg1) {
|
||||||
CHECK_OPT_EXTENSION_SET(&mysql->options);
|
CHECK_OPT_EXTENSION_SET(&mysql->options);
|
||||||
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, auto_local_infile, *(uint*)arg1 == LOCAL_INFILE_MODE_AUTO
|
mysql->extension->auto_local_infile= *(uint*)arg1 == LOCAL_INFILE_MODE_AUTO
|
||||||
? WAIT_FOR_QUERY : ALWAYS_ACCEPT);
|
? WAIT_FOR_QUERY : ALWAYS_ACCEPT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MYSQL_INIT_COMMAND:
|
case MYSQL_INIT_COMMAND:
|
||||||
|
Reference in New Issue
Block a user