diff --git a/src/LibHac/Fs/Common/PathFormatter.cs b/src/LibHac/Fs/Common/PathFormatter.cs index 08e4ddc2..16075f43 100644 --- a/src/LibHac/Fs/Common/PathFormatter.cs +++ b/src/LibHac/Fs/Common/PathFormatter.cs @@ -155,7 +155,7 @@ public static class PathFormatter currentPath = path.Slice(1); } - else if (path.Length != 0 && WindowsPath.IsWindowsDrive(path.Slice(1))) + else if (WindowsPath.IsWindowsDrive(path.Slice(1))) { if (normalizeBuffer.Length == 0) return ResultFs.NotNormalized.Log(); @@ -356,8 +356,12 @@ public static class PathFormatter if (path.At(0) == Dot && (path.At(1) == NullTerminator || path.At(1) == DirectorySeparator || path.At(1) == AltDirectorySeparator)) { - if (relativePathBuffer.Length >= 2) + if (relativePathBuffer.Length != 0) { + // Note: Nintendo doesn't check if the buffer is long enough here + if (relativePathBuffer.Length < 2) + return ResultFs.TooLongPath.Log(); + relativePathBuffer[0] = Dot; relativePathBuffer[1] = NullTerminator; } diff --git a/src/LibHac/FsSrv/Impl/FileSystemInterfaceAdapter.cs b/src/LibHac/FsSrv/Impl/FileSystemInterfaceAdapter.cs index f33caf1f..04250601 100644 --- a/src/LibHac/FsSrv/Impl/FileSystemInterfaceAdapter.cs +++ b/src/LibHac/FsSrv/Impl/FileSystemInterfaceAdapter.cs @@ -49,7 +49,7 @@ public class FileInterfaceAdapter : IFileSf if (offset < 0) return ResultFs.InvalidOffset.Log(); - if (destination.Size < 0) + if (size < 0) return ResultFs.InvalidSize.Log(); if (destination.Size < (int)size) @@ -78,7 +78,7 @@ public class FileInterfaceAdapter : IFileSf if (offset < 0) return ResultFs.InvalidOffset.Log(); - if (source.Size < 0) + if (size < 0) return ResultFs.InvalidSize.Log(); if (source.Size < (int)size) diff --git a/src/LibHac/FsSrv/Impl/StorageInterfaceAdapter.cs b/src/LibHac/FsSrv/Impl/StorageInterfaceAdapter.cs index ef40a0cf..fa916e95 100644 --- a/src/LibHac/FsSrv/Impl/StorageInterfaceAdapter.cs +++ b/src/LibHac/FsSrv/Impl/StorageInterfaceAdapter.cs @@ -33,7 +33,7 @@ public class StorageInterfaceAdapter : IStorageSf if (offset < 0) return ResultFs.InvalidOffset.Log(); - if (destination.Size < 0) + if (size < 0) return ResultFs.InvalidSize.Log(); if (destination.Size < size) @@ -58,7 +58,7 @@ public class StorageInterfaceAdapter : IStorageSf if (offset < 0) return ResultFs.InvalidOffset.Log(); - if (source.Size < 0) + if (size < 0) return ResultFs.InvalidSize.Log(); if (source.Size < size)