Makes Start-Trace escape file paths correctly (#3863)

Start-Trace neglects qualifying arguments to the -o and -pf command line
switches, causing logman (and subsequently Start-Trace) to exit with
0x80070057 and return:

Error:
The argument is incorrect.

Whenever arguments to either -ProviderFilePath or -OutputFilePath
contain spaces because Start-Trace doesn't escape the path in any way.

This commit moves basic input validation for output file paths to the
ProviderFilePath and OutputFilePath parameter definitions, and adds text
qualifiers (double-quotes) around input arguments
This commit is contained in:
Mathias R. Jessen 2017-08-05 00:26:51 +02:00 committed by Travis Plunk
parent 7d5367a9f7
commit f15a8dab28

View file

@ -27,9 +27,11 @@ function Start-Trace
[string]
$SessionName,
[Parameter(Position=1)]
[ValidateNotNullOrEmpty()]
[string]
$OutputFilePath,
[Parameter(Position=2)]
[ValidateNotNullOrEmpty()]
[string]
$ProviderFilePath,
[Parameter()]
@ -63,12 +65,12 @@ function Start-Trace
if ($null -ne $OutputFilePath)
{
$executestring += " -o $OutputFilePath"
$executestring += " -o ""$OutputFilePath"""
}
if ($null -ne $ProviderFilePath)
{
$executestring += " -pf $ProviderFilePath"
$executestring += " -pf ""$ProviderFilePath"""
}
if ($null -ne $Format)