mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-23 04:12:02 +00:00
Add maximum instruction opcode bounds check (thanks hthh)
This commit is contained in:
parent
34af93b72f
commit
862aa73783
1 changed files with 6 additions and 0 deletions
|
@ -273,6 +273,11 @@ bool DmntCheatManager::ParseCheats(const char *s, size_t len) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Bounds check the opcode count. */
|
||||||
|
if (cur_entry->definition.num_opcodes >= sizeof(cur_entry->definition.opcodes)/sizeof(cur_entry->definition.opcodes[0])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* We're parsing an instruction, so validate it's 8 hex digits. */
|
/* We're parsing an instruction, so validate it's 8 hex digits. */
|
||||||
for (size_t j = 1; j < 8; j++) {
|
for (size_t j = 1; j < 8; j++) {
|
||||||
/* Validate 8 hex chars. */
|
/* Validate 8 hex chars. */
|
||||||
|
@ -286,6 +291,7 @@ bool DmntCheatManager::ParseCheats(const char *s, size_t len) {
|
||||||
memcpy(hex_str, &s[i], 8);
|
memcpy(hex_str, &s[i], 8);
|
||||||
cur_entry->definition.opcodes[cur_entry->definition.num_opcodes++] = strtoul(hex_str, NULL, 16);
|
cur_entry->definition.opcodes[cur_entry->definition.num_opcodes++] = strtoul(hex_str, NULL, 16);
|
||||||
|
|
||||||
|
|
||||||
/* Skip onwards. */
|
/* Skip onwards. */
|
||||||
i += 8;
|
i += 8;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue