mirror of https://github.com/mgba-emu/mgba.git
All: Fix handling of strncat bounds
This commit is contained in:
parent
72817df4cf
commit
3357fa6a03
|
@ -169,14 +169,14 @@ void mCoreConfigDeinit(struct mCoreConfig* config) {
|
|||
|
||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||
bool mCoreConfigLoad(struct mCoreConfig* config) {
|
||||
char path[PATH_MAX];
|
||||
char path[PATH_MAX + 1];
|
||||
mCoreConfigDirectory(path, PATH_MAX);
|
||||
strncat(path, PATH_SEP "config.ini", PATH_MAX - strlen(path));
|
||||
return mCoreConfigLoadPath(config, path);
|
||||
}
|
||||
|
||||
bool mCoreConfigSave(const struct mCoreConfig* config) {
|
||||
char path[PATH_MAX];
|
||||
char path[PATH_MAX + 1];
|
||||
mCoreConfigDirectory(path, PATH_MAX);
|
||||
strncat(path, PATH_SEP "config.ini", PATH_MAX - strlen(path));
|
||||
return mCoreConfigSavePath(config, path);
|
||||
|
@ -304,7 +304,7 @@ void mCoreConfigPortablePath(char* out, size_t outLength) {
|
|||
CFRelease(suburl);
|
||||
}
|
||||
#endif
|
||||
strncat(out, PATH_SEP "portable.ini", outLength - strlen(out));
|
||||
strncat(out, PATH_SEP "portable.ini", outLength - strlen(out) - 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ int main(int argc, char* argv[]) {
|
|||
int ok = 1;
|
||||
|
||||
mCoreConfigDirectory(bin, sizeof(bin));
|
||||
strncat(bin, "/updater.log", sizeof(bin));
|
||||
strncat(bin, "/updater.log", sizeof(bin) - 1);
|
||||
logfile = fopen(bin, "w");
|
||||
|
||||
mCoreConfigInit(&config, "updater");
|
||||
|
|
|
@ -607,16 +607,16 @@ static void _GBCoreReset(struct mCore* core) {
|
|||
switch (gb->model) {
|
||||
case GB_MODEL_DMG:
|
||||
case GB_MODEL_MGB: // TODO
|
||||
strncat(path, PATH_SEP "gb_bios.bin", PATH_MAX - strlen(path));
|
||||
strncat(path, PATH_SEP "gb_bios.bin", PATH_MAX - strlen(path) - 1);
|
||||
break;
|
||||
case GB_MODEL_SGB:
|
||||
case GB_MODEL_SGB2: // TODO
|
||||
strncat(path, PATH_SEP "sgb_bios.bin", PATH_MAX - strlen(path));
|
||||
strncat(path, PATH_SEP "sgb_bios.bin", PATH_MAX - strlen(path) - 1);
|
||||
break;
|
||||
case GB_MODEL_CGB:
|
||||
case GB_MODEL_AGB:
|
||||
case GB_MODEL_SCGB:
|
||||
strncat(path, PATH_SEP "gbc_bios.bin", PATH_MAX - strlen(path));
|
||||
strncat(path, PATH_SEP "gbc_bios.bin", PATH_MAX - strlen(path) - 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -684,7 +684,7 @@ static void _GBACoreReset(struct mCore* core) {
|
|||
if (!found) {
|
||||
char path[PATH_MAX];
|
||||
mCoreConfigDirectory(path, PATH_MAX);
|
||||
strncat(path, PATH_SEP "gba_bios.bin", PATH_MAX - strlen(path));
|
||||
strncat(path, PATH_SEP "gba_bios.bin", PATH_MAX - strlen(path) - 1);
|
||||
bios = VFileOpen(path, O_RDONLY);
|
||||
if (bios && GBAIsBIOS(bios)) {
|
||||
found = true;
|
||||
|
|
Loading…
Reference in New Issue