Merge pull request #1412 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:yay_plugins to develop

* commit '9cc406633c29d4167031dc85b950858f90163cbc':
  Fixed plugin loading so it actually checks the plugin type.
This commit is contained in:
Dana Robinson 2018-12-27 16:10:57 -06:00
commit 5b57c69ed4
2 changed files with 15 additions and 2 deletions

View File

@ -311,6 +311,7 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key,
hbool_t *success, const void **plugin_info)
{
H5PL_HANDLE handle = NULL;
H5PL_get_plugin_type_t get_plugin_type = NULL;
H5PL_get_plugin_info_t get_plugin_info = NULL;
herr_t ret_value = SUCCEED;
@ -333,12 +334,22 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key,
HGOTO_DONE(SUCCEED)
}
/* Return a handle for the function H5PLget_plugin_type in the dynamic library.
* The plugin library is supposed to define this function.
*/
if (NULL == (get_plugin_type = (H5PL_get_plugin_type_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_type")))
HGOTO_DONE(SUCCEED)
/* Return a handle for the function H5PLget_plugin_info in the dynamic library.
* The plugin library is suppose to define this function.
* The plugin library is supposed to define this function.
*/
if (NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_info")))
HGOTO_DONE(SUCCEED)
/* Check the plugin type and return if it doesn't match the one passed in */
if(type != (H5PL_type_t)(*get_plugin_type)())
HGOTO_DONE(SUCCEED)
/* Get the plugin information */
switch (type) {
case H5PL_TYPE_FILTER:
@ -364,7 +375,7 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key,
/* Get the plugin info */
if(NULL == (cls = (const H5VL_class_t *)(*get_plugin_info)()))
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL driver info from plugin")
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL connector info from plugin")
/* Which kind of key are we looking for? */
if(key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) {

View File

@ -79,6 +79,7 @@
/* maximum size for expanding env vars */
# define H5PL_EXPAND_BUFFER_SIZE 32767
typedef H5PL_type_t(__cdecl *H5PL_get_plugin_type_t)(void);
typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void);
#else /* H5_HAVE_WIN32_API */
@ -105,6 +106,7 @@
/* Clear error */
# define H5PL_CLR_ERROR HERROR(H5E_PLUGIN, H5E_CANTGET, "can't dlopen:%s", dlerror())
typedef H5PL_type_t(*H5PL_get_plugin_type_t)(void);
typedef const void *(*H5PL_get_plugin_info_t)(void);
#endif /* H5_HAVE_WIN32_API */