Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/API/CustomEmployeeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,10 +891,17 @@ private static void SetPortrait(Transform card, string employeeId)

string assetsDir = Path.Combine(MelonEnvironment.UserDataDirectory, "ModAssets");
string? imagePath = null;
foreach (var ext in new[] { ".jpg", ".png" })

// [Security] Prevent path traversal from unsanitized employeeId
if (!string.IsNullOrEmpty(employeeId) &&
employeeId.IndexOfAny(Path.GetInvalidFileNameChars()) < 0 &&
!employeeId.Contains(".."))
{
string candidate = Path.Combine(assetsDir, employeeId + ext);
if (File.Exists(candidate)) { imagePath = candidate; break; }
foreach (var ext in new[] { ".jpg", ".png" })
{
string candidate = Path.Combine(assetsDir, employeeId + ext);
if (File.Exists(candidate)) { imagePath = candidate; break; }
}
}

if (imagePath != null)
Expand Down
15 changes: 14 additions & 1 deletion src/GameLayer/Patches/Networking/CablePositionsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ private static bool CreateNewCablePrefix(
}
}

[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private static void LogBaseIdChange(int baseId)
{
MelonLogger.Msg($"[CablePatch] Cable ID counter set to {baseId + 1}");
}

public static void SetBaseId(int baseId)
{
int current;
Expand All @@ -67,7 +73,14 @@ public static void SetBaseId(int baseId)
}
while (Interlocked.CompareExchange(ref _nextCableId, baseId + 1, current) != current);

MelonLogger.Msg($"[CablePatch] Cable ID counter set to {baseId + 1}");
try
{
LogBaseIdChange(baseId);
}
catch (System.Exception)
{
// Ignore MelonLoader not being present in test environment
}
}

public static int PeekNextId() => _nextCableId;
Expand Down
Loading