mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-22 10:45:28 +00:00
Added input stream property checks.
This commit is contained in:
parent
5670cb7e16
commit
ece2906cde
|
@ -60,6 +60,10 @@ void nstool::AssetProcess::importHeader()
|
|||
{
|
||||
throw tc::Exception(mModuleName, "No file reader set.");
|
||||
}
|
||||
if (mFile->canRead() == false || mFile->canSeek() == false)
|
||||
{
|
||||
throw tc::NotSupportedException(mModuleName, "Input stream requires read/seek permissions.");
|
||||
}
|
||||
|
||||
if (mFile->length() < tc::io::IOUtil::castSizeToInt64(sizeof(nn::hac::sAssetHeader)))
|
||||
{
|
||||
|
|
|
@ -44,6 +44,10 @@ void nstool::CnmtProcess::importCnmt()
|
|||
{
|
||||
throw tc::Exception(mModuleName, "No file reader set.");
|
||||
}
|
||||
if (mFile->canRead() == false || mFile->canSeek() == false)
|
||||
{
|
||||
throw tc::NotSupportedException(mModuleName, "Input stream requires read/seek permissions.");
|
||||
}
|
||||
|
||||
// check if file_size is greater than 20MB, don't import.
|
||||
size_t cnmt_file_size = tc::io::IOUtil::castInt64ToSize(mFile->length());
|
||||
|
|
|
@ -53,6 +53,10 @@ void nstool::EsTikProcess::importTicket()
|
|||
{
|
||||
throw tc::Exception(mModuleName, "No file reader set.");
|
||||
}
|
||||
if (mFile->canRead() == false || mFile->canSeek() == false)
|
||||
{
|
||||
throw tc::NotSupportedException(mModuleName, "Input stream requires read/seek permissions.");
|
||||
}
|
||||
|
||||
// check if file_size is greater than 20MB, don't import.
|
||||
size_t file_size = tc::io::IOUtil::castInt64ToSize(mFile->length());
|
||||
|
|
|
@ -44,12 +44,16 @@ void nstool::NacpProcess::importNacp()
|
|||
{
|
||||
throw tc::Exception(mModuleName, "No file reader set.");
|
||||
}
|
||||
|
||||
// check if file_size is greater than 20MB, don't import.
|
||||
size_t file_size = tc::io::IOUtil::castInt64ToSize(mFile->length());
|
||||
if (file_size > (0x100000 * 20))
|
||||
if (mFile->canRead() == false || mFile->canSeek() == false)
|
||||
{
|
||||
throw tc::Exception(mModuleName, "File too large.");
|
||||
throw tc::NotSupportedException(mModuleName, "Input stream requires read/seek permissions.");
|
||||
}
|
||||
|
||||
// check if file_size does matches expected size
|
||||
size_t file_size = tc::io::IOUtil::castInt64ToSize(mFile->length());
|
||||
if (file_size != sizeof(nn::hac::sApplicationControlProperty))
|
||||
{
|
||||
throw tc::Exception(mModuleName, "File was incorrect size.");
|
||||
}
|
||||
|
||||
// read cnmt
|
||||
|
|
|
@ -78,6 +78,10 @@ void nstool::PfsProcess::importHeader()
|
|||
{
|
||||
throw tc::Exception(mModuleName, "No file reader set.");
|
||||
}
|
||||
if (mFile->canRead() == false || mFile->canSeek() == false)
|
||||
{
|
||||
throw tc::NotSupportedException(mModuleName, "Input stream requires read/seek permissions.");
|
||||
}
|
||||
|
||||
tc::ByteData scratch;
|
||||
|
||||
|
|
|
@ -71,6 +71,10 @@ void nstool::RomfsProcess::importHeader()
|
|||
{
|
||||
throw tc::Exception(mModuleName, "No file reader set.");
|
||||
}
|
||||
if (mFile->canRead() == false || mFile->canSeek() == false)
|
||||
{
|
||||
throw tc::NotSupportedException(mModuleName, "Input stream requires read/seek permissions.");
|
||||
}
|
||||
|
||||
tc::ByteData scratch;
|
||||
|
||||
|
|
Loading…
Reference in a new issue