Check length

This commit is contained in:
Jaex 2024-02-21 08:01:38 +03:00
parent 856a1a057c
commit 280f3c5f8f

View file

@ -42,6 +42,7 @@ public class SingleInstanceManager : IDisposable
private const string MutexName = "82E6AC09-0FEF-4390-AD9F-0DD3F5561EFC";
private const string AppName = "ShareX";
private static readonly string PipeName = $"{Environment.MachineName}-{Environment.UserName}-{AppName}";
private const int MaxArgumentsLength = 100;
private readonly Mutex mutex;
private CancellationTokenSource cts;
@ -103,6 +104,11 @@ private async Task ListenForConnectionsAsync()
{
int length = reader.ReadInt32();
if (length < 0 || length > MaxArgumentsLength)
{
throw new Exception("Invalid length: " + length);
}
string[] args = new string[length];
for (int i = 0; i < length; i++)