Browse Source

Possible fix for bug #590

This change reduces the risk of LADSPA plugins referencing
Audacity symbols by using the RTLD_DEEPBIND flag when loading
the plugins.

It also addresses an issue specific to the "blop" plugins where
they load their own libraries (without RTLD_DEEPBIND).

A much better solution would be to change Audacity's default
symbol visibility to "hidden" which would expose ONLY symbols
specificially marked as visible.
au-ny-api
Leland Lucius 3 years ago
parent
commit
5955dbc752
  1. 8
      lib-src/libnyquist/nyquist/cmt/cmtcmd.c
  2. 2
      lib-src/libnyquist/nyquist/cmt/cmtcmd.h
  3. 4
      lib-src/libnyquist/nyquist/cmt/seqread.c
  4. 27
      src/effects/ladspa/LadspaEffect.cpp

8
lib-src/libnyquist/nyquist/cmt/cmtcmd.c

@ -14,7 +14,7 @@
#define HASHELEM(p) ((p).symbol_name)
#define HASHVAL 50
#define HASHENTRIES 50
#define HASHENTER lookup
#define HASHENTER hash_lookup
#define HASHNOCOPY
#include "hashrout.h"
@ -23,7 +23,7 @@ void defvar(name, addr)
char *name;
int *addr;
{
int i = lookup(name);
int i = hash_lookup(name);
HASHENTRY(i).symb_type = var_symb_type;
HASHENTRY(i).ptr.intptr = addr;
}
@ -33,7 +33,7 @@ void defun(name, addr)
char *name;
int (*addr)();
{
int i = lookup(name);
int i = hash_lookup(name);
HASHENTRY(i).symb_type = fn_symb_type;
HASHENTRY(i).ptr.routine = addr;
}
@ -44,7 +44,7 @@ void defvec(name, addr, size)
int *addr;
int size;
{
int i = lookup(name);
int i = hash_lookup(name);
HASHENTRY(i).symb_type = vec_symb_type;
HASHENTRY(i).size = size;
HASHENTRY(i).ptr.intptr = addr;

2
lib-src/libnyquist/nyquist/cmt/cmtcmd.h

@ -25,7 +25,7 @@ typedef struct symb_descr {
} ptr;
} symb_descr_node;
int lookup(char *s);
int hash_lookup(char *s);
void defvar(char *name, int *addr);
void defvec(char *name, int *addr, int size);
typedef int (*defun_type)();

4
lib-src/libnyquist/nyquist/cmt/seqread.c

@ -471,7 +471,7 @@ private void docall()
if (fieldx == 1) fferror("Routine name expected");
else if (token[fieldx] != '(') fferror("Open paren expected");
else {
desc = &HASHENTRY(lookup(symbol));
desc = &HASHENTRY(hash_lookup(symbol));
if (!desc->symb_type) {
fieldx = 0;
fferror("Function not defined");
@ -1038,7 +1038,7 @@ private void doset(vec_flag)
linex += scan();
if (!token[0]) fferror("Variable name expected");
else {
struct symb_descr *desc = &HASHENTRY(lookup(token));
struct symb_descr *desc = &HASHENTRY(hash_lookup(token));
if (!desc->symb_type) fferror("Called function not defined");
else if (vec_flag && (desc->symb_type != vec_symb_type)) {
fferror("This is not an array");

27
src/effects/ladspa/LadspaEffect.cpp

@ -27,6 +27,14 @@ effects from this one class.
#include <float.h>
#if !defined(__WXMSW__)
#include <dlfcn.h>
#ifndef RTLD_DEEPBIND
#define RTLD_DEEPBIND 0
#endif
#endif
#include <wx/setup.h> // for wxUSE_* macros
#include <wx/wxprec.h>
#include <wx/button.h>
@ -260,11 +268,18 @@ unsigned LadspaEffectsModule::DiscoverPluginsAtPath(
int index = 0;
int nLoaded = 0;
LADSPA_Descriptor_Function mainFn = NULL;
#if defined(__WXMSW__)
wxDynamicLibrary lib;
if (lib.Load(path, wxDL_NOW)) {
wxLogNull logNo;
mainFn = (LADSPA_Descriptor_Function) lib.GetSymbol(wxT("ladspa_descriptor"));
#else
void *lib = dlopen((const char *)path.ToUTF8(), RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
if (lib) {
mainFn = (LADSPA_Descriptor_Function) dlsym(lib, "ladspa_descriptor");
#endif
if (mainFn) {
const LADSPA_Descriptor *data;
@ -283,6 +298,7 @@ unsigned LadspaEffectsModule::DiscoverPluginsAtPath(
else
errMsg = _("Could not load the library");
#if defined(__WXMSW__)
if (lib.IsLoaded()) {
// PRL: I suspect Bug1257 -- Crash when enabling Amplio2 -- is the fault of a timing-
// dependent multi-threading bug in the Amplio2 library itself, in case the unload of the .dll
@ -291,6 +307,11 @@ unsigned LadspaEffectsModule::DiscoverPluginsAtPath(
::wxMilliSleep(10);
lib.Unload();
}
#else
if (lib) {
dlclose(lib);
}
#endif
wxSetWorkingDirectory(saveOldCWD);
hadpath ? wxSetEnv(wxT("PATH"), envpath) : wxUnsetEnv(wxT("PATH"));
@ -355,8 +376,12 @@ FilePaths LadspaEffectsModule::GetSearchPaths()
// No special paths...probably should look in %CommonProgramFiles%\LADSPA
#else
pathList.push_back(wxGetHomeDir() + wxFILE_SEP_PATH + wxT(".ladspa"));
#if defined(__LP64__)
pathList.push_back(wxT("/usr/local/lib64/ladspa"));
pathList.push_back(wxT("/usr/lib64/ladspa"));
#endif
pathList.push_back(wxT("/usr/local/lib/ladspa"));
pathList.push_back(wxT("/usr/lib/ladspa"));
pathList.push_back(wxT(LIBDIR) wxT("/ladspa"));

Loading…
Cancel
Save