maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #02596
[Branch ~maria-captains/maria/5.1] Rev 2832: 1. don't crash on failing to load a plugin with newer MYSQL_PLUGIN_INTERFACE_VERSION
------------------------------------------------------------
revno: 2832
committer: Sergei Golubchik <sergii@xxxxxxxxx>
branch nick: maria-5.1
timestamp: Fri 2010-03-12 20:05:21 +0100
message:
1. don't crash on failing to load a plugin with newer MYSQL_PLUGIN_INTERFACE_VERSION
2. don't copy st_mysql_plugin structure unnecessary (sizeof hasn't changed)
modified:
sql/sql_plugin.cc
sql/sql_plugin.h
--
lp:maria
https://code.launchpad.net/~maria-captains/maria/5.1
Your team Maria developers is subscribed to branch lp:maria.
To unsubscribe from this branch go to https://code.launchpad.net/~maria-captains/maria/5.1/+edit-subscription.
=== modified file 'sql/sql_plugin.cc'
--- sql/sql_plugin.cc 2010-03-09 19:23:30 +0000
+++ sql/sql_plugin.cc 2010-03-12 19:05:21 +0000
@@ -333,7 +333,7 @@
dlclose(p->handle);
#endif
my_free(p->dl.str, MYF(MY_ALLOW_ZERO_PTR));
- if (p->version != MYSQL_PLUGIN_INTERFACE_VERSION)
+ if (p->allocated)
my_free((uchar*)p->plugins, MYF(MY_ALLOW_ZERO_PTR));
}
@@ -454,33 +454,37 @@
#endif
}
- for (i= 0;
- ((struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
- /* no op */;
-
- cur= (struct st_mysql_plugin*)
- my_malloc(i*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
- if (!cur)
+ if (sizeof_st_plugin != sizeof(st_mysql_plugin))
{
- free_plugin_mem(&plugin_dl);
- if (report & REPORT_TO_USER)
- my_error(ER_OUTOFMEMORY, MYF(0), plugin_dl.dl.length);
- if (report & REPORT_TO_LOG)
- sql_print_error(ER(ER_OUTOFMEMORY), plugin_dl.dl.length);
- DBUG_RETURN(0);
+ for (i= 0;
+ ((struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
+ i++)
+ /* no op */;
+
+ cur= (struct st_mysql_plugin*)
+ my_malloc((i+1)*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
+ if (!cur)
+ {
+ free_plugin_mem(&plugin_dl);
+ if (report & REPORT_TO_USER)
+ my_error(ER_OUTOFMEMORY, MYF(0), plugin_dl.dl.length);
+ if (report & REPORT_TO_LOG)
+ sql_print_error(ER(ER_OUTOFMEMORY), plugin_dl.dl.length);
+ DBUG_RETURN(0);
+ }
+ /*
+ All st_plugin fields not initialized in the plugin explicitly, are
+ set to 0. It matches C standard behaviour for struct initializers that
+ have less values than the struct definition.
+ */
+ for (i=0;
+ (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
+ i++)
+ memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
+
+ sym= cur;
+ plugin_dl.allocated= true;
}
- /*
- All st_plugin fields not initialized in the plugin explicitly, are
- set to 0. It matches C standard behaviour for struct initializers that
- have less values than the struct definition.
- */
- for (i=0;
- (old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
- i++)
- memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
-
- sym= cur;
}
plugin_dl.plugins= (struct st_mysql_plugin *)sym;
=== modified file 'sql/sql_plugin.h'
--- sql/sql_plugin.h 2010-03-08 13:57:32 +0000
+++ sql/sql_plugin.h 2010-03-12 19:05:21 +0000
@@ -63,7 +63,8 @@
LEX_STRING dl;
void *handle;
struct st_mysql_plugin *plugins;
- int version;
+ int version;
+ bool allocated;
uint ref_count; /* number of plugins loaded from the library */
};