From 3b70af007a183520b8822bc4a12dd049c0bfa9e0 Mon Sep 17 00:00:00 2001 From: "Mathias R. Jessen" Date: Thu, 25 May 2017 19:20:11 +0200 Subject: [PATCH] Makes Start-Trace escape file paths correctly 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 --- .../Windows-Core+Full/PSDiagnostics/PSDiagnostics.psm1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Modules/Windows-Core+Full/PSDiagnostics/PSDiagnostics.psm1 b/src/Modules/Windows-Core+Full/PSDiagnostics/PSDiagnostics.psm1 index 1c67c2b7510..3861be8e0b6 100644 --- a/src/Modules/Windows-Core+Full/PSDiagnostics/PSDiagnostics.psm1 +++ b/src/Modules/Windows-Core+Full/PSDiagnostics/PSDiagnostics.psm1 @@ -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 ($OutputFilePath -ne $null) { - $executestring += " -o $OutputFilePath" + $executestring += " -o ""$OutputFilePath""" } if ($ProviderFilePath -ne $null) { - $executestring += " -pf $ProviderFilePath" + $executestring += " -pf ""$ProviderFilePath""" } if ($Format -ne $null)