Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ComponentArgs passed in through the command line may be passed twice to the command if the id and display_name of the component are the same. #48

Open
icnocop opened this Issue · 0 comments

1 participant

@icnocop
Collaborator

ComponentArgs passed in through the command line may be passed twice to the command if the id and display_name of the component are the same.

For example,

dotNetInstaller.xml:

<component command="#CABPATH\Setup.exe" id="Setup" display_name="Setup" type="cmd">
 <embedfile sourcefilepath="C:\Setup.exe" />
</component>

setup built from dotNetInstaller is run as follows:

SetupInstaller.exe /Log /ComponentArgs "Setup":"/param1"

Log file snippet:

...
Extracting: C:\Users\ADMINI~1\AppData\Local\Temp\{...}\Setup.exe
Done: C:\Users\ADMINI~1\AppData\Local\Temp\{...}\Setup.exe
-- Additional component 'Setup' argument (Setup): /param1
-- Additional component 'Setup' argument (Setup): /param1
-- Additional component 'Setup' arguments:  /param1 /param1
Executing: C:\Users\ADMINI~1\AppData\Local\Temp\{...}\Setup.exe  /param1 /param1
...

Also notice the two spaces before the command line arguments when only one is expected.

The main issue exists in .\dotNetInstallerLib\Component.cpp, line 197:

std::wstring Component::GetAdditionalCmd() const
{
    std::wstring cmd;
    std::wstring cmds[] = { L"*", id, GetDisplayName() };

    for (int i = 0; i < ARRAYSIZE(cmds); i++)
    {
        std::map<std::wstring, std::wstring>::iterator cmd_iter = InstallerSession::Instance->AdditionalCmdLineArgs.find(cmds[i]);
        if (cmd_iter != InstallerSession::Instance->AdditionalCmdLineArgs.end())
        {
            cmd.append(L" ");
            cmd.append(cmd_iter->second);
            LOG(L"-- Additional component '" << id << L"' argument (" << cmds[i] << L"): " << cmd_iter->second);
        }
    }

    if (! cmd.empty())
    {
        LOG(L"-- Additional component '" << id << L"' arguments: " << cmd);
    }

    return cmd;
}

Notice that cmds[] is iterated with both the id and display name to build the complete command line.
I expected that if id == display_name, then cmds[] should only contain L"*" and id for example.

The issue with the additional space in the command line exists in .\dotNetInstallerLib\CmdComponent.cpp, line 36:

std::wstring additional_cmd = GetAdditionalCmd();
if (! additional_cmd.empty())
{
    l_command.append(L" ");
    l_command.append(additional_cmd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.