mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-10 06:01:52 +00:00
dmnt: Truncate cheat names after maxlen instead of failing
This commit is contained in:
parent
fe2dd671fb
commit
89c484414b
1 changed files with 6 additions and 6 deletions
|
@ -739,13 +739,13 @@ namespace sts::dmnt::cheat::impl {
|
|||
size_t j = i + 1;
|
||||
while (s[j] != ']') {
|
||||
j++;
|
||||
if (j >= len || (j - i - 1) >= sizeof(cur_entry->definition.readable_name)) {
|
||||
if (j >= len) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* s[i+1:j] is cheat name. */
|
||||
const size_t cheat_name_len = (j - i - 1);
|
||||
const size_t cheat_name_len = std::min(j - i - 1, sizeof(cur_entry->definition.readable_name));
|
||||
std::memcpy(cur_entry->definition.readable_name, &s[i+1], cheat_name_len);
|
||||
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
||||
|
||||
|
@ -764,13 +764,13 @@ namespace sts::dmnt::cheat::impl {
|
|||
size_t j = i + 1;
|
||||
while (s[j] != '}') {
|
||||
j++;
|
||||
if (j >= len || (j - i - 1) >= sizeof(cur_entry->definition.readable_name)) {
|
||||
if (j >= len) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* s[i+1:j] is cheat name. */
|
||||
const size_t cheat_name_len = (j - i - 1);
|
||||
const size_t cheat_name_len = std::min(j - i - 1, sizeof(cur_entry->definition.readable_name));
|
||||
memcpy(cur_entry->definition.readable_name, &s[i+1], cheat_name_len);
|
||||
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
||||
|
||||
|
@ -837,13 +837,13 @@ namespace sts::dmnt::cheat::impl {
|
|||
size_t j = i + 1;
|
||||
while (s[j] != ']') {
|
||||
j++;
|
||||
if (j >= len || (j - i - 1) >= sizeof(cur_cheat_name)) {
|
||||
if (j >= len) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* s[i+1:j] is cheat name. */
|
||||
const size_t cheat_name_len = (j - i - 1);
|
||||
const size_t cheat_name_len = std::min(j - i - 1, sizeof(cur_cheat_name));
|
||||
std::memcpy(cur_cheat_name, &s[i+1], cheat_name_len);
|
||||
cur_cheat_name[cheat_name_len] = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue