mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add some basic sanity checks to ParamSFO reader (could add more)
This commit is contained in:
parent
21686a6a93
commit
9c017e03f9
2 changed files with 11 additions and 4 deletions
|
@ -103,19 +103,22 @@ bool ParamSFOData::ReadSFO(const u8 *paramsfo, size_t size) {
|
|||
|
||||
const IndexTable *indexTables = (const IndexTable *)(paramsfo + sizeof(Header));
|
||||
|
||||
if (header->key_table_start > size || header->data_table_start > size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const u8 *key_start = paramsfo + header->key_table_start;
|
||||
const u8 *data_start = paramsfo + header->data_table_start;
|
||||
|
||||
for (u32 i = 0; i < header->index_table_entries; i++)
|
||||
{
|
||||
const char *key = (const char *)(key_start + indexTables[i].key_table_offset);
|
||||
|
||||
switch (indexTables[i].param_fmt) {
|
||||
case 0x0404:
|
||||
{
|
||||
// Unsigned int
|
||||
const u32_le *data = (const u32_le *)(data_start + indexTables[i].data_table_offset);
|
||||
SetValue(key,*data,indexTables[i].param_max_len);
|
||||
SetValue(key, *data, indexTables[i].param_max_len);
|
||||
VERBOSE_LOG(LOADER, "%s %08x", key, *data);
|
||||
}
|
||||
break;
|
||||
|
@ -132,7 +135,7 @@ bool ParamSFOData::ReadSFO(const u8 *paramsfo, size_t size) {
|
|||
{
|
||||
const char *utfdata = (const char *)(data_start + indexTables[i].data_table_offset);
|
||||
VERBOSE_LOG(LOADER, "%s %s", key, utfdata);
|
||||
SetValue(key,std::string(utfdata /*, indexTables[i].param_len*/), indexTables[i].param_max_len);
|
||||
SetValue(key, std::string(utfdata /*, indexTables[i].param_len*/), indexTables[i].param_max_len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,11 @@ public:
|
|||
bool WriteSFO(u8 **paramsfo, size_t *size);
|
||||
|
||||
bool ReadSFO(const std::vector<u8> ¶msfo) {
|
||||
return ReadSFO(¶msfo[0], paramsfo.size());
|
||||
if (!paramsfo.empty()) {
|
||||
return ReadSFO(¶msfo[0], paramsfo.size());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int GetDataOffset(const u8 *paramsfo, std::string dataName);
|
||||
|
|
Loading…
Add table
Reference in a new issue