factory: do more version checks

So that we don't accidentally load an old plugin.
This commit is contained in:
Wim Taymans 2020-04-22 18:10:26 +02:00
parent 539be881ba
commit 4cb2d58e89
6 changed files with 23 additions and 2 deletions

View file

@ -113,6 +113,8 @@ static int load_handle(struct data *data, struct spa_handle **handle, const char
printf("can't enumerate factories: %s\n", spa_strerror(res));
break;
}
if (factory->version < 1)
continue;
if (strcmp(factory->name, name))
continue;
@ -207,6 +209,8 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
printf("can't enumerate factories: %s\n", spa_strerror(res));
break;
}
if (factory->version < 1)
continue;
if (strcmp(factory->name, name))
continue;

View file

@ -160,6 +160,8 @@ static int make_node(struct data *data, struct spa_node **node, const char *lib,
printf("can't enumerate factories: %s\n", spa_strerror(res));
break;
}
if (factory->version < 1)
continue;
if (strcmp(factory->name, name))
continue;
@ -437,6 +439,8 @@ static int load_handle(struct data *data, struct spa_handle **handle, const char
printf("can't enumerate factories: %s\n", spa_strerror(res));
break;
}
if (factory->version < 1)
continue;
if (strcmp(factory->name, name))
continue;

View file

@ -113,6 +113,8 @@ static int load_handle(struct data *data, struct spa_handle **handle, const char
printf("can't enumerate factories: %s\n", spa_strerror(res));
break;
}
if (factory->version < 1)
continue;
if (strcmp(factory->name, name))
continue;

View file

@ -205,8 +205,8 @@ static void inspect_factory(struct data *data, const struct spa_handle_factory *
printf("factory version:\t\t%d\n", factory->version);
printf("factory name:\t\t'%s'\n", factory->name);
if (factory->version < SPA_VERSION_HANDLE_FACTORY) {
printf("\tno further info for version < %d\n", SPA_VERSION_HANDLE_FACTORY);
if (factory->version < 1) {
printf("\tno further info for version %d < 1\n", factory->version);
return;
}

View file

@ -184,6 +184,12 @@ int main(int argc, char *argv[])
break;
}
if (factory->version < 1) {
printf("factories version %d < %d not supported\n",
factory->version, 1);
continue;
}
for (iidx = 0;;) {
const struct spa_interface_info *info;

View file

@ -172,6 +172,11 @@ static const struct spa_handle_factory *find_factory(struct plugin *plugin, cons
break;
goto out;
}
if (factory->version < 1) {
pw_log_warn("factory version %d < 1 not supported",
factory->version);
continue;
}
if (strcmp(factory->name, factory_name) == 0)
return factory;
}