From cc30332487c1e49dc6c528a66d4685701d239627 Mon Sep 17 00:00:00 2001 From: kichik Date: Wed, 4 Sep 2002 14:28:10 +0000 Subject: [PATCH] Now only accepts plug-in calls in the form of dllname[.dll]::FunctionName Prevents clashes with future commands git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@904 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/Plugins.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Source/Plugins.cpp b/Source/Plugins.cpp index 2eb88f2b..99c74f73 100644 --- a/Source/Plugins.cpp +++ b/Source/Plugins.cpp @@ -136,24 +136,28 @@ bool Plugins::IsPluginCommand(char* token) char* Plugins::GetPluginDll(char* command) { - if (strstr(command,"::")) - return m_commands.find(command); + bool malloced = false; + char *colons = strstr(command,"::"); + if (!colons) return 0; - // slow & stupid but it doesn't matter - int i = 0,pos = 0; - char* signatures = m_commands.defines.get(); - while (pos != -1) - { - pos = m_commands.defines.idx2pos(i++); - if (pos >= 0) - { - char* cmd = strstr(signatures+pos,"::"); - if (cmd && strcmp(cmd+2,command) == 0) - return m_commands.find(signatures+pos); - } + *colons = 0; + + char *p = command; + + while (*p != '.' && *p) p++; + + if (lstrcmpi(p, ".dll")) { + char *new_command = (char *)malloc(lstrlen(command)+1+4); + wsprintf(new_command, "%s.dll::%s", command, colons+2); + command = new_command; + malloced = 1; } - - return 0; + + *colons = ':'; + + char *result = m_commands.find(command); + if (malloced) free(command); + return result; } void Plugins::StoreInstDLL(char* dllName)