Awoo-Installer
Awoo-Installer copied to clipboard
Fix for NCZ/NSZ cert installs to prevent crash on install
Currently a random crash happens when installing from NCZ/NSZ files. This is down to the cert file entry in the file entry table having a corrupt file extension name. When the cert tries to install, the filename extension is wrong which causes a crash.
This bug is random, but can be fixed by modding nsp.cpp and xci.cpp to the following,
std::vector<const PFS0FileEntry*> NSP::GetFileEntriesByExtension(std::string extension)
{
std::vector<const PFS0FileEntry*> entryList;
for (unsigned int i = 0; i < this->GetBaseHeader()->numFiles; i++)
{
const PFS0FileEntry* fileEntry = this->GetFileEntry(i);
std::string name(this->GetFileEntryName(fileEntry));
auto foundExtension = name.substr(name.find(".") + 1);
// fix cert filename extension becoming corrupted when xcz/nsz is installing certs.
std::string cert ("cert");
std::size_t found = name.find(cert);
if (found!=std::string::npos){
int pos = 0;
std::string mystr = name;
pos = mystr.find_last_of('.');
mystr = mystr.substr(5, pos);
foundExtension = mystr.substr(mystr.find(".") + 1);
}
if (foundExtension == extension)
entryList.push_back(fileEntry);
}
return entryList;
}
This looks for a file entry with cert in the name and then strips off the excess bytes/chars from the extension so that the filename in the entry table is corrected. This then prevents the crash while trying to install the cert.
Regards.
No pull request?
I made a pull request #195 that implements this fix. This has not been tested.