Skip to content

Commit 5a7a799

Browse files
committed
Backport from mysql-trunk to mysql-5.6 of:
------------------------------------------------------------ revno: 5657 committer: Tor Didriksen <[email protected]> branch nick: trunk-merge timestamp: Thu 2013-05-02 11:24:38 +0200 message: Bug#13252623 UNPORTABLE USAGE OF VA_LIST IN SQL-COMMON/CLIENT_PLUGIN.C The literal '0' isn't necessarily a valid VA_LIST.
1 parent 3ef7390 commit 5a7a799

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

sql-common/client_plugin.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -117,8 +117,9 @@ find_plugin(const char *name, int type)
117117
@retval a pointer to an installed plugin or 0
118118
*/
119119
static struct st_mysql_client_plugin *
120-
add_plugin(MYSQL *mysql, struct st_mysql_client_plugin *plugin, void *dlhandle,
121-
int argc, va_list args)
120+
do_add_plugin(MYSQL *mysql, struct st_mysql_client_plugin *plugin,
121+
void *dlhandle,
122+
int argc, va_list args)
122123
{
123124
const char *errmsg;
124125
struct st_client_plugin_int plugin_int, *p;
@@ -179,6 +180,31 @@ add_plugin(MYSQL *mysql, struct st_mysql_client_plugin *plugin, void *dlhandle,
179180
return NULL;
180181
}
181182

183+
184+
static struct st_mysql_client_plugin *
185+
add_plugin_noargs(MYSQL *mysql, struct st_mysql_client_plugin *plugin,
186+
void *dlhandle,
187+
int argc, ...)
188+
{
189+
struct st_mysql_client_plugin *retval= NULL;
190+
va_list ap;
191+
va_start(ap, argc);
192+
retval= do_add_plugin(mysql, plugin, dlhandle, argc, ap);
193+
va_end(ap);
194+
return retval;
195+
}
196+
197+
198+
static struct st_mysql_client_plugin *
199+
add_plugin_withargs(MYSQL *mysql, struct st_mysql_client_plugin *plugin,
200+
void *dlhandle,
201+
int argc, va_list args)
202+
{
203+
return do_add_plugin(mysql, plugin, dlhandle, argc, args);
204+
}
205+
206+
207+
182208
/**
183209
Loads plugins which are specified in the environment variable
184210
LIBMYSQL_PLUGINS.
@@ -249,7 +275,7 @@ int mysql_client_plugin_init()
249275
mysql_mutex_lock(&LOCK_load_client_plugin);
250276

251277
for (builtin= mysql_client_builtins; *builtin; builtin++)
252-
add_plugin(&mysql, *builtin, 0, 0, 0);
278+
add_plugin_noargs(&mysql, *builtin, 0, 0);
253279

254280
mysql_mutex_unlock(&LOCK_load_client_plugin);
255281

@@ -307,7 +333,7 @@ mysql_client_register_plugin(MYSQL *mysql,
307333
plugin= NULL;
308334
}
309335
else
310-
plugin= add_plugin(mysql, plugin, 0, 0, 0);
336+
plugin= add_plugin_noargs(mysql, plugin, 0, 0);
311337

312338
mysql_mutex_unlock(&LOCK_load_client_plugin);
313339
return plugin;
@@ -420,7 +446,7 @@ mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
420446
goto err;
421447
}
422448

423-
plugin= add_plugin(mysql, plugin, dlhandle, argc, args);
449+
plugin= add_plugin_withargs(mysql, plugin, dlhandle, argc, args);
424450

425451
mysql_mutex_unlock(&LOCK_load_client_plugin);
426452

0 commit comments

Comments
 (0)