I am using Process.Start in a Windows Service I created to execute an exe that I have on my server that is used for audio conversion. I am passing some user input as a parameter to this exe. The code looks something like this:
string filePath = "\ffmpeg.exe";
string parameters = String.Format(@"-i ""{0}"" -f mp3 ""{1}""",
LocalFileName,
tempDirectory + NewFileName);
ProcessStartInfo startInfo = new ProcessStartInfo(ffmpegPath, parameters);
Process proc = Process.Start(startInfo);
The variables LocalFileName
and NewFileName
are set from user input. If I want to protect against OS Injection, is it sufficient to strip out any &
characters or is there more that I should be doing?
test & timeout 1000
&
as I mentioned above... Are you saying this isn't possible? Just to clarify - you do know what&
does in the Windows command prompt correct?