Skip to content

Commit

Permalink
[xharness] Validate input when serving files in the web view. (#21949)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Jan 14, 2025
1 parent 3ffc1da commit 6416719
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/xharness/Jenkins/TestServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,16 @@ IEnumerable<ITestTask> find_tasks (StreamWriter writer, string ids)
jenkins.GenerateReport ();
}

if (serveFile is null)
if (serveFile is null) {
serveFile = Path.Combine (Path.GetDirectoryName (jenkins.LogDirectory), request.Url.LocalPath.Substring (1));
serveFile = Path.GetFullPath (serveFile);
if (!serveFile.StartsWith (Path.GetDirectoryName (Path.GetFullPath (jenkins.LogDirectory)) + Path.DirectorySeparatorChar)) {
Console.WriteLine ($"400: {request.Url.LocalPath}");
response.StatusCode = 400;
response.OutputStream.WriteByte ((byte) '?');
break;
}
}
var path = serveFile;
if (File.Exists (path)) {
var buffer = new byte [4096];
Expand Down

0 comments on commit 6416719

Please sign in to comment.