mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Block explicit layout types in sandboxing.
This commit is contained in:
@@ -193,6 +193,10 @@ namespace Robust.Shared.ContentPack
|
||||
|
||||
_sawmill.Debug($"Unmanaged methods... {fullStopwatch.ElapsedMilliseconds}ms");
|
||||
|
||||
CheckNoTypeAbuse(reader, errors);
|
||||
|
||||
_sawmill.Debug($"Type abuse... {fullStopwatch.ElapsedMilliseconds}ms");
|
||||
|
||||
CheckMemberReferences(loadedConfig, members, errors);
|
||||
|
||||
foreach (var error in errors)
|
||||
@@ -311,6 +315,27 @@ namespace Robust.Shared.ContentPack
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckNoTypeAbuse(MetadataReader reader, ConcurrentBag<SandboxError> errors)
|
||||
{
|
||||
foreach (var typeDefHandle in reader.TypeDefinitions)
|
||||
{
|
||||
var typeDef = reader.GetTypeDefinition(typeDefHandle);
|
||||
if ((typeDef.Attributes & TypeAttributes.ExplicitLayout) != 0)
|
||||
{
|
||||
// The C# compiler emits explicit layout types for some array init logic. These have no fields.
|
||||
// Only ban explicit layout if it has fields.
|
||||
|
||||
var type = GetTypeFromDefinition(reader, typeDefHandle);
|
||||
|
||||
if (typeDef.GetFields().Count > 0)
|
||||
{
|
||||
var err = $"Explicit layout type {type} may not have fields.";
|
||||
errors.Add(new SandboxError(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckMemberReferences(
|
||||
SandboxConfig sandboxConfig,
|
||||
List<MMemberRef> members,
|
||||
|
||||
33
Robust.Shared/Timing/ProfilingManager.cs
Normal file
33
Robust.Shared/Timing/ProfilingManager.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Utility.Collections;
|
||||
|
||||
namespace Robust.Shared.Timing;
|
||||
|
||||
// No interfaces here,
|
||||
public sealed class ProfilingManager
|
||||
{
|
||||
public bool IsEnabled;
|
||||
|
||||
// I don't care that this isn't a tree I will call upon the string tree just like in BYOND.
|
||||
private readonly Dictionary<string, int> _stringTreeIndices = new();
|
||||
private ValueList<string> _stringTree;
|
||||
|
||||
public struct Cmd
|
||||
{
|
||||
public CmdType Type;
|
||||
|
||||
public int StringId;
|
||||
public float Value;
|
||||
}
|
||||
|
||||
public struct CmdSample
|
||||
{
|
||||
// public
|
||||
}
|
||||
|
||||
public enum CmdType
|
||||
{
|
||||
Invalid,
|
||||
Sample
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user