mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-28 15:07:04 -04:00
String safety (#1548)
* Array size UB fixes * Fix ShieldD * Remove (almost) all unsafe strcpy calls Bunch of macros. C arrays are easy enough and just need a different call. For various cases where a char* is passed around bare, I've made a TEXT_SPAN macro that can store a length too for bounds checking. * Move crash handling in safe string operations to separate TU * strcat safe version * sprintf made safe too * Fix compile
This commit is contained in:
committed by
GitHub
parent
af162bbd0a
commit
a6376368ee
+7
-7
@@ -908,7 +908,7 @@ void dName_c::setNameText() {
|
||||
#if REGION_JPN
|
||||
if (mChrInfo[i].mMojiSet == 2) {
|
||||
#endif
|
||||
sprintf(mNameText[i],
|
||||
SAFE_SPRINTF(mNameText[i],
|
||||
"\x1b"
|
||||
"CD\x1b"
|
||||
"CR\x1b"
|
||||
@@ -919,7 +919,7 @@ void dName_c::setNameText() {
|
||||
);
|
||||
#if REGION_JPN
|
||||
} else {
|
||||
sprintf(mNameText[i],
|
||||
SAFE_SPRINTF(mNameText[i],
|
||||
"\x1b"
|
||||
"CD\x1b"
|
||||
"CR\x1b"
|
||||
@@ -1330,7 +1330,7 @@ void dName_c::mojiListChange() {
|
||||
|
||||
char buf[74];
|
||||
for (int i = 0; i < 65; i++) {
|
||||
strcpy(buf, "\x1B"
|
||||
SAFE_STRCPY(buf, "\x1B"
|
||||
"CD"
|
||||
"\x1B"
|
||||
"CR"
|
||||
@@ -1338,15 +1338,15 @@ void dName_c::mojiListChange() {
|
||||
"CC[000000]"
|
||||
"\x1B"
|
||||
"GM[0]");
|
||||
strcat(buf, mojiSet[i]);
|
||||
strcat(buf, "\x1B"
|
||||
SAFE_STRCAT(buf, mojiSet[i]);
|
||||
SAFE_STRCAT(buf, "\x1B"
|
||||
"HM"
|
||||
"\x1B"
|
||||
"CC[ffffff]"
|
||||
"\x1B"
|
||||
"GM[0]");
|
||||
strcat(buf, mojiSet[i]);
|
||||
strcpy(mMojiText[i], buf);
|
||||
SAFE_STRCAT(buf, mojiSet[i]);
|
||||
SAFE_STRCPY(mMojiText[i], buf);
|
||||
}
|
||||
|
||||
#if TARGET_PC || REGION_PAL || REGION_JPN
|
||||
|
||||
Reference in New Issue
Block a user