mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-27 09:32:53 +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;
|
size_t j = i + 1;
|
||||||
while (s[j] != ']') {
|
while (s[j] != ']') {
|
||||||
j++;
|
j++;
|
||||||
if (j >= len || (j - i - 1) >= sizeof(cur_entry->definition.readable_name)) {
|
if (j >= len) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* s[i+1:j] is cheat name. */
|
/* 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);
|
std::memcpy(cur_entry->definition.readable_name, &s[i+1], cheat_name_len);
|
||||||
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
||||||
|
|
||||||
|
@ -764,13 +764,13 @@ namespace sts::dmnt::cheat::impl {
|
||||||
size_t j = i + 1;
|
size_t j = i + 1;
|
||||||
while (s[j] != '}') {
|
while (s[j] != '}') {
|
||||||
j++;
|
j++;
|
||||||
if (j >= len || (j - i - 1) >= sizeof(cur_entry->definition.readable_name)) {
|
if (j >= len) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* s[i+1:j] is cheat name. */
|
/* 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);
|
memcpy(cur_entry->definition.readable_name, &s[i+1], cheat_name_len);
|
||||||
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
||||||
|
|
||||||
|
@ -837,13 +837,13 @@ namespace sts::dmnt::cheat::impl {
|
||||||
size_t j = i + 1;
|
size_t j = i + 1;
|
||||||
while (s[j] != ']') {
|
while (s[j] != ']') {
|
||||||
j++;
|
j++;
|
||||||
if (j >= len || (j - i - 1) >= sizeof(cur_cheat_name)) {
|
if (j >= len) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* s[i+1:j] is cheat name. */
|
/* 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);
|
std::memcpy(cur_cheat_name, &s[i+1], cheat_name_len);
|
||||||
cur_cheat_name[cheat_name_len] = 0;
|
cur_cheat_name[cheat_name_len] = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue