mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Catch errors when checking an AesXtsFile's size
This commit is contained in:
parent
0ed67d87df
commit
39f952015f
1 changed files with 13 additions and 6 deletions
|
@ -44,15 +44,22 @@ namespace LibHac.IO
|
||||||
|
|
||||||
private long GetAesXtsFileSize(string path)
|
private long GetAesXtsFileSize(string path)
|
||||||
{
|
{
|
||||||
using (IFile file = BaseFileSystem.OpenFile(path, OpenMode.Read))
|
try
|
||||||
{
|
{
|
||||||
var buffer = new byte[8];
|
using (IFile file = BaseFileSystem.OpenFile(path, OpenMode.Read))
|
||||||
|
{
|
||||||
|
var buffer = new byte[8];
|
||||||
|
|
||||||
file.Read(buffer, 0x20);
|
file.Read(buffer, 0x20);
|
||||||
if (BitConverter.ToUInt32(buffer, 0) != 0x3058414E) return 0;
|
if (BitConverter.ToUInt32(buffer, 0) != 0x3058414E) return 0;
|
||||||
|
|
||||||
file.Read(buffer, 0x48);
|
file.Read(buffer, 0x48);
|
||||||
return BitConverter.ToInt32(buffer, 0);
|
return BitConverter.ToInt32(buffer, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ArgumentOutOfRangeException)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue