Skip to content

Commit

Permalink
Add plugin ABI versioning checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Jul 13, 2016
1 parent 9d37708 commit 23f069a
Show file tree
Hide file tree
Showing 30 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions aac.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,3 +535,4 @@ const int ip_priority = 50;
const char * const ip_extensions[] = { "aac", NULL };
const char * const ip_mime_types[] = { "audio/aac", "audio/aacp", NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,4 @@ const struct output_plugin_opt op_pcm_options[] = {
};

const int op_priority = 0;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions ao.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,4 @@ const struct output_plugin_opt op_pcm_options[] = {
};

const int op_priority = 3;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions arts.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ const struct output_plugin_opt op_pcm_options[] = {
};

const int op_priority = 4;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions cdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,4 @@ const struct input_plugin_opt ip_options[] = {
const int ip_priority = 50;
const char * const ip_extensions[] = { NULL };
const char * const ip_mime_types[] = { "x-content/audio-cdda", NULL };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions coreaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,3 +872,4 @@ const struct mixer_plugin_opt op_mixer_options[] = {
};

const int op_priority = 1;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions cue.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,4 @@ const int ip_priority = 50;
const char * const ip_extensions[] = { NULL };
const char * const ip_mime_types[] = { "application/x-cue", NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,3 +685,4 @@ const char *const ip_extensions[] = {
};
const char *const ip_mime_types[] = { NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions flac.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,3 +589,4 @@ const int ip_priority = 50;
const char * const ip_extensions[] = { "flac", "fla", NULL };
const char * const ip_mime_types[] = { NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
10 changes: 10 additions & 0 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ void ip_load_plugins(void)
void *so;
char *ext;
const int *priority_ptr;
const unsigned *abi_version_ptr;
bool err = false;

if (d->d_name[0] == '.')
continue;
Expand All @@ -529,13 +531,21 @@ void ip_load_plugins(void)

ip = xnew(struct ip, 1);

abi_version_ptr = dlsym(so, "ip_abi_version");
priority_ptr = dlsym(so, "ip_priority");
ip->extensions = dlsym(so, "ip_extensions");
ip->mime_types = dlsym(so, "ip_mime_types");
ip->ops = dlsym(so, "ip_ops");
ip->options = dlsym(so, "ip_options");
if (!priority_ptr || !ip->extensions || !ip->mime_types || !ip->ops || !ip->options) {
error_msg("%s: missing symbol", filename);
err = true;
}
if (!abi_version_ptr || *abi_version_ptr != IP_ABI_VERSION) {
error_msg("%s: incompatible plugin version", filename);
err = true;
}
if (err) {
free(ip);
dlclose(so);
continue;
Expand Down
3 changes: 3 additions & 0 deletions ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <unistd.h>
#endif

#define IP_ABI_VERSION 1

enum {
/* no error */
IP_ERROR_SUCCESS,
Expand Down Expand Up @@ -109,5 +111,6 @@ extern const int ip_priority;
extern const char * const ip_extensions[];
extern const char * const ip_mime_types[];
extern const struct input_plugin_opt ip_options[];
extern const unsigned ip_abi_version;

#endif
1 change: 1 addition & 0 deletions jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,4 @@ const struct output_plugin_opt op_pcm_options[] = {
};

const int op_priority = 2;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,4 @@ const char * const ip_mime_types[] = {
"audio/mpeg", "audio/x-mp3", "audio/x-mpeg", NULL
};
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions mikmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,4 @@ const char * const ip_extensions[] = {
};
const char * const ip_mime_types[] = { NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions modplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,4 @@ const char * const ip_extensions[] = {
};
const char * const ip_mime_types[] = { NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions mp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,4 @@ const int ip_priority = 50;
const char * const ip_extensions[] = { "mp4", "m4a", "m4b", NULL };
const char * const ip_mime_types[] = { /*"audio/mp4", "audio/mp4a-latm",*/ NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions mpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,4 @@ const int ip_priority = 50;
const char *const ip_extensions[] = { "mpc", "mpp", "mp+", NULL };
const char *const ip_mime_types[] = { "audio/x-musepack", NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
3 changes: 3 additions & 0 deletions op.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <fcntl.h>
#endif

#define OP_ABI_VERSION 1

enum {
/* no error */
OP_ERROR_SUCCESS,
Expand Down Expand Up @@ -75,5 +77,6 @@ struct output_plugin_opt {
extern const struct output_plugin_ops op_pcm_ops;
extern const struct output_plugin_opt op_pcm_options[];
extern const int op_priority;
extern const unsigned op_abi_version;

#endif
1 change: 1 addition & 0 deletions opus.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,4 @@ const int ip_priority = 50;
const char * const ip_extensions[] = { "opus", NULL };
const char * const ip_mime_types[] = { NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions oss.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,4 @@ const struct output_plugin_opt op_pcm_options[] = {
};

const int op_priority = 1;
const unsigned op_abi_version = OP_ABI_VERSION;
10 changes: 10 additions & 0 deletions output.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ void op_load_plugins(void)
struct output_plugin *plug;
void *so, *symptr;
char *ext;
const unsigned *abi_version_ptr;
bool err = false;

if (d->d_name[0] == '.')
continue;
Expand All @@ -117,8 +119,16 @@ void op_load_plugins(void)
plug->pcm_ops = dlsym(so, "op_pcm_ops");
plug->pcm_options = dlsym(so, "op_pcm_options");
symptr = dlsym(so, "op_priority");
abi_version_ptr = dlsym(so, "op_abi_version");
if (!plug->pcm_ops || !plug->pcm_options || !symptr) {
error_msg("%s: missing symbol", filename);
err = true;
}
if (!abi_version_ptr || *abi_version_ptr != OP_ABI_VERSION) {
error_msg("%s: incompatible plugin version", filename);
err = true;
}
if (err) {
free(plug);
dlclose(so);
continue;
Expand Down
1 change: 1 addition & 0 deletions pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,3 +595,4 @@ const struct mixer_plugin_opt op_mixer_options[] = {
};

const int op_priority = -2;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions roar.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,4 @@ const struct mixer_plugin_opt op_mixer_options[] = {
};

const int op_priority = -1;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions sndio.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,4 @@ const struct mixer_plugin_opt op_mixer_options[] = {
};

const int op_priority = 2;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions sun.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,4 @@ const struct output_plugin_opt op_pcm_options[] = {
};

const int op_priority = 0;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions vorbis.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,4 @@ const int ip_priority = 50;
const char * const ip_extensions[] = { "ogg", "oga", "ogx", NULL };
const char * const ip_mime_types[] = { "application/ogg", "audio/x-ogg", NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions vtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,4 @@ const int ip_priority = 50;
const char * const ip_extensions[] = {"vtx", NULL};
const char * const ip_mime_types[] = { NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions wav.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,4 @@ const int ip_priority = 50;
const char * const ip_extensions[] = { "wav", NULL };
const char * const ip_mime_types[] = { NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;
1 change: 1 addition & 0 deletions waveout.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,4 @@ const struct output_plugin_opt op_pcm_options[] = {
};

const int op_priority = 0;
const unsigned op_abi_version = OP_ABI_VERSION;
1 change: 1 addition & 0 deletions wavpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,4 @@ const int ip_priority = 50;
const char * const ip_extensions[] = { "wv", NULL };
const char * const ip_mime_types[] = { "audio/x-wavpack", NULL };
const struct input_plugin_opt ip_options[] = { { NULL } };
const unsigned ip_abi_version = IP_ABI_VERSION;

0 comments on commit 23f069a

Please sign in to comment.