Skip to content

Commit

Permalink
[tests] Validate input when serving files in ProxyTest. (#21951)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Jan 14, 2025
1 parent 1c16bfd commit 3ffc1da
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/monotouch-test/CoreFoundation/ProxyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public void Setup ()
var context = listener.GetContext ();
var request = context.Request;
var pacPath = Path.Combine (NSBundle.MainBundle.ResourcePath, request.RawUrl.Substring (1));
pacPath = Path.GetFullPath (pacPath);
if (!pacPath.StartsWith (Path.GetFullPath (NSBundle.MainBundle.ResourcePath) + Path.DirectorySeparatorChar))
throw new InvalidOperationException ($"Invalid access: {request.RawUrl}");
Console.WriteLine ($" Serving {pacPath}");
var buf = File.ReadAllBytes (pacPath);
context.Response.ContentLength64 = buf.Length;
Expand Down

0 comments on commit 3ffc1da

Please sign in to comment.