Skip to content

Commit

Permalink
components: don't use a VLA for allocating the plugin symbol name
Browse files Browse the repository at this point in the history
Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Feb 24, 2020
1 parent 38e218b commit 0760e6d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions hwloc/components.c
Expand Up @@ -81,6 +81,7 @@ hwloc__dlforeach_cb(const char *filename, void *_data __hwloc_attribute_unused)
lt_dlhandle handle;
struct hwloc_component *component;
struct hwloc__plugin_desc *desc, **prevdesc;
char *componentsymbolname;

if (hwloc_plugins_verbose)
fprintf(stderr, "Plugin dlforeach found `%s'\n", filename);
Expand All @@ -105,16 +106,23 @@ hwloc__dlforeach_cb(const char *filename, void *_data __hwloc_attribute_unused)
goto out;
}

{
char componentsymbolname[strlen(basename)+10+1];
componentsymbolname = malloc(strlen(basename)+10+1);
if (!componentsymbolname) {
if (hwloc_plugins_verbose)
fprintf(stderr, "Failed to allocation component `%s' symbol\n",
basename);
goto out_with_handle;
}
sprintf(componentsymbolname, "%s_component", basename);
component = lt_dlsym(handle, componentsymbolname);
if (!component) {
if (hwloc_plugins_verbose)
fprintf(stderr, "Failed to find component symbol `%s'\n",
componentsymbolname);
free(componentsymbolname);
goto out_with_handle;
}
free(componentsymbolname);
if (component->abi != HWLOC_COMPONENT_ABI) {
if (hwloc_plugins_verbose)
fprintf(stderr, "Plugin symbol ABI %u instead of %d\n",
Expand All @@ -124,7 +132,6 @@ hwloc__dlforeach_cb(const char *filename, void *_data __hwloc_attribute_unused)
if (hwloc_plugins_verbose)
fprintf(stderr, "Plugin contains expected symbol `%s'\n",
componentsymbolname);
}

if (HWLOC_COMPONENT_TYPE_DISC == component->type) {
if (strncmp(basename, "hwloc_", 6)) {
Expand Down

0 comments on commit 0760e6d

Please sign in to comment.