From 64f53f1a536cd871b2948cbea30869d68b37f98e Mon Sep 17 00:00:00 2001 From: Fridrich Štrba Date: Wed, 15 Sep 2010 16:49:01 +0200 Subject: Increase safety on Windows Call SetDllDirectory() to reduce risk of DLL hijacking, and call SetProcessDEPPolicy() to reduce risk of rogue code execution. --- addressbook/tools/evolution-addressbook-export.c | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'addressbook') diff --git a/addressbook/tools/evolution-addressbook-export.c b/addressbook/tools/evolution-addressbook-export.c index 58831ed16c..9c495e5b5f 100644 --- a/addressbook/tools/evolution-addressbook-export.c +++ b/addressbook/tools/evolution-addressbook-export.c @@ -30,6 +30,20 @@ #include "evolution-addressbook-export.h" +#ifdef G_OS_WIN32 +#ifdef DATADIR +#undef DATADIR +#endif +#include +#include +#ifndef PROCESS_DEP_ENABLE +#define PROCESS_DEP_ENABLE 0x00000001 +#endif +#ifndef PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION +#define PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION 0x00000002 +#endif +#endif + /* Command-Line Options */ static gchar *opt_output_file = NULL; static gboolean opt_list_folders_mode = FALSE; @@ -75,6 +89,28 @@ main (gint argc, gchar **argv) gint IsCSV = FALSE; gint IsVCard = FALSE; +#ifdef G_OS_WIN32 + /* Reduce risks */ + { + typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName); + t_SetDllDirectoryA p_SetDllDirectoryA; + + p_SetDllDirectoryA = GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetDllDirectoryA"); + if (p_SetDllDirectoryA) + (*p_SetDllDirectoryA) (""); + } +#ifndef _WIN64 + { + typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags); + t_SetProcessDEPPolicy p_SetProcessDEPPolicy; + + p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetProcessDEPPolicy"); + if (p_SetProcessDEPPolicy) + (*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE|PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION); + } +#endif +#endif + g_type_init (); /*i18n-lize */ -- cgit