diff options
author | Andre Heider | 2010-09-15 07:44:08 +0000 |
---|---|---|
committer | Andre Heider | 2010-09-15 07:44:08 +0000 |
commit | 2596143e2bc42f5958e446ba6c156402ee1a8d53 (patch) | |
tree | 27838a251050826a5a59574f2064f70365900c1f /backends/plugins | |
parent | 76ca653972f5513d46c00889b57c7a13e41859a9 (diff) | |
download | scummvm-rg350-2596143e2bc42f5958e446ba6c156402ee1a8d53.tar.gz scummvm-rg350-2596143e2bc42f5958e446ba6c156402ee1a8d53.tar.bz2 scummvm-rg350-2596143e2bc42f5958e446ba6c156402ee1a8d53.zip |
PLUGINS: Additional plugin check for the ELF loader.
The ELF loader does not have access to the symbols of the main
executable, it just relocates symbols to it via fixed offsets. We need
to make sure that loaded plugins are from the same link process to
prevent crashes. An embedded build date is used for that.
svn-id: r52730
Diffstat (limited to 'backends/plugins')
-rw-r--r-- | backends/plugins/elf/elf-provider.cpp | 13 | ||||
-rw-r--r-- | backends/plugins/elf/elf-provider.h | 2 | ||||
-rw-r--r-- | backends/plugins/elf/plugin.syms | 1 | ||||
-rw-r--r-- | backends/plugins/elf/version.cpp | 32 | ||||
-rw-r--r-- | backends/plugins/elf/version.h | 35 |
5 files changed, 83 insertions, 0 deletions
diff --git a/backends/plugins/elf/elf-provider.cpp b/backends/plugins/elf/elf-provider.cpp index 8629de6c45..d1c8f6aa05 100644 --- a/backends/plugins/elf/elf-provider.cpp +++ b/backends/plugins/elf/elf-provider.cpp @@ -112,6 +112,19 @@ bool ELFPlugin::loadPlugin() { return false; } + CharFunc buildDateFunc = (CharFunc)findSymbol("PLUGIN_getBuildDate"); + if (!buildDateFunc) { + unloadPlugin(); + warning("elfloader: plugin '%s' is missing symbols", _filename.c_str()); + return false; + } + + if (strncmp(gScummVMPluginBuildDate, buildDateFunc(), strlen(gScummVMPluginBuildDate))) { + unloadPlugin(); + warning("elfloader: plugin '%s' has a different build date", _filename.c_str()); + return false; + } + bool ret = DynamicPlugin::loadPlugin(); #ifdef ELF_LOADER_CXA_ATEXIT diff --git a/backends/plugins/elf/elf-provider.h b/backends/plugins/elf/elf-provider.h index 92fe5d63d1..0309ffcece 100644 --- a/backends/plugins/elf/elf-provider.h +++ b/backends/plugins/elf/elf-provider.h @@ -45,6 +45,8 @@ */ class ELFPlugin : public DynamicPlugin { protected: + typedef const char *(*CharFunc)(); + DLObject *_dlHandle; Common::String _filename; void *_dso_handle; diff --git a/backends/plugins/elf/plugin.syms b/backends/plugins/elf/plugin.syms index 24ee1a19dc..70465ae976 100644 --- a/backends/plugins/elf/plugin.syms +++ b/backends/plugins/elf/plugin.syms @@ -1,3 +1,4 @@ +PLUGIN_getBuildDate PLUGIN_getVersion PLUGIN_getType PLUGIN_getTypeVersion diff --git a/backends/plugins/elf/version.cpp b/backends/plugins/elf/version.cpp new file mode 100644 index 0000000000..0277c6ae1c --- /dev/null +++ b/backends/plugins/elf/version.cpp @@ -0,0 +1,32 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "backends/plugins/elf/version.h" + +#ifdef USE_ELF_LOADER +const char *gScummVMPluginBuildDate __attribute__((visibility("hidden"))) = + __DATE__ " " __TIME__ ; +#endif + diff --git a/backends/plugins/elf/version.h b/backends/plugins/elf/version.h new file mode 100644 index 0000000000..726204aeb7 --- /dev/null +++ b/backends/plugins/elf/version.h @@ -0,0 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef BACKENDS_PLUGINS_ELF_VERSION_H +#define BACKENDS_PLUGINS_ELF_VERSION_H + +#include "common/scummsys.h" + +#ifdef USE_ELF_LOADER +extern const char *gScummVMPluginBuildDate; +#endif + +#endif + |