Security Issue behoben, Anonyme Pipes als Lösung
This commit is contained in:
@@ -33,6 +33,7 @@ using DevExpress.Xpf.Core;
|
||||
using DevExpress.Xpf.Grid;
|
||||
using DevExpress.XtraScheduler;
|
||||
using System.IO.Pipes;
|
||||
using System.Threading;
|
||||
|
||||
namespace BeWo
|
||||
{
|
||||
@@ -749,31 +750,7 @@ namespace BeWo
|
||||
DataControlBase.AllowInfiniteGridSize = true;
|
||||
|
||||
RenderTier = RenderCapability.Tier >> 16;
|
||||
|
||||
var args = e.Args;
|
||||
|
||||
//args = new string[] { "tedemo?undemo?pwdemo?ip?sn1?cs" };
|
||||
|
||||
if (args.Length > 0)
|
||||
{
|
||||
using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, args[0]))
|
||||
{
|
||||
using (StreamReader sr = new StreamReader(pipeClient))
|
||||
{
|
||||
string temp = string.Empty;
|
||||
|
||||
while (!temp.StartsWith("c137"))
|
||||
{
|
||||
temp = sr.ReadLine();
|
||||
}
|
||||
|
||||
temp = sr.ReadLine();
|
||||
|
||||
Loader.Load(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
base.OnStartup(e);
|
||||
|
||||
Dispatcher.UnhandledException += (s, ex)
|
||||
@@ -791,7 +768,36 @@ namespace BeWo
|
||||
|
||||
FrameworkElement.LanguageProperty.OverrideMetadata(typeof (FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
|
||||
|
||||
}
|
||||
var args = e.Args;
|
||||
|
||||
//args = new string[] { "tedemo?undemo?pwdemo?ip?sn1?cs" };
|
||||
try
|
||||
{
|
||||
if (args.Length > 0)
|
||||
{
|
||||
using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, args[0]))
|
||||
{
|
||||
using (StreamReader sr = new StreamReader(pipeClient))
|
||||
{
|
||||
string temp = string.Empty;
|
||||
|
||||
while (!temp.StartsWith("C-137"))
|
||||
{
|
||||
temp = sr.ReadLine();
|
||||
}
|
||||
|
||||
temp = sr.ReadLine();
|
||||
|
||||
Loader.Load(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void ReloadSettings(List<SettingsDC> settings)
|
||||
{
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace BeWoLauncher
|
||||
public static LauncherWindow Window { get; set; }
|
||||
public static LauncherApp CurrentLauncher => Current as LauncherApp;
|
||||
|
||||
public static Process PlanerProcess { get; set; }
|
||||
public static bool PlanerRunning
|
||||
private static Process PlanerProcess { get; set; }
|
||||
private static bool PlanerRunning
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -113,6 +113,7 @@ namespace BeWoLauncher
|
||||
|
||||
public static void StartBeWo()
|
||||
{
|
||||
// based on https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-use-anonymous-pipes-for-local-interprocess-communication?redirectedfrom=MSDN
|
||||
PlanerProcess = new Process();
|
||||
|
||||
PlanerProcess.StartInfo.FileName = UpdatePathManager.GetPlanerPath();
|
||||
@@ -132,7 +133,7 @@ namespace BeWoLauncher
|
||||
{
|
||||
sw.AutoFlush = true;
|
||||
|
||||
sw.WriteLine("c137");
|
||||
sw.WriteLine("C-137");
|
||||
pipeServer.WaitForPipeDrain();
|
||||
|
||||
sw.WriteLine(ConnectionInformation.Connection.ToString());
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BeWoLauncher
|
||||
|
||||
if (string.IsNullOrWhiteSpace(installLocation))
|
||||
{
|
||||
installLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BeWoPlaner");
|
||||
installLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, GetMainExeName());
|
||||
}
|
||||
|
||||
return installLocation;
|
||||
@@ -84,9 +84,10 @@ namespace BeWoLauncher
|
||||
{
|
||||
return Directory.CreateDirectory(GetApplyPath());
|
||||
}
|
||||
public static string GetMainExeName() => "BeWoPlaner.exe";
|
||||
public static string GetPlanerPath()
|
||||
{
|
||||
return Path.Combine(GetApplyPath(), "BeWoPlaner.exe");
|
||||
return Path.Combine(GetApplyPath(), GetMainExeName());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user