Fix Buffer Overflows (#28)

* Update code_800AF9B0.c

* Update code_80005FD0.c

* Update code_800029B0.c

* Update code_80091750.c

* Update code_80091750.h

* Update code_80005FD0.c
This commit is contained in:
MegaMech
2024-07-31 21:51:00 -06:00
committed by GitHub
parent fee2dc308a
commit 48a8342f3f
5 changed files with 38 additions and 33 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ u16 D_8015F890;
u16 D_8015F892;
u16 D_8015F894;
// Indexed by Player ID. Track time in seconds since player has last crossed the finish line
f32 gTimePlayerLastTouchedFinishLine[8];
f32 gTimePlayerLastTouchedFinishLine[NUM_PLAYERS];
u8 *gNmiUnknown1;
u8 *gNmiUnknown2;
+1 -1
View File
@@ -103,7 +103,7 @@ u16 D_80163318[12];
u16 D_80163330[10];
u16 D_80163344[2];
u16 D_80163348[2];
u16 D_8016334C[2];
u16 D_8016334C[8]; // Increased from 2 to 8 to prevent array overflow.
u16 gSpeedKartAIBehaviour[12];
s32 D_80163368[4];
s32 D_80163378;
+31 -16
View File
@@ -59,8 +59,7 @@ s8 D_8018D9D8;
s8 D_8018D9D9;
struct_8018D9E0_entry D_8018D9E0[D_8018D9E0_SIZE];
struct_8018DEE0_entry D_8018DEE0[D_8018DEE0_SIZE];
struct_8018E060_entry D_8018E060[D_8018E060_SIZE];
UNUSED u8 code_80091750_bss_padding0[8];
struct_8018E060_entry D_8018E060[D_8018E060_SIZE + 1];
struct_8018E0E8_entry D_8018E0E8[D_8018E0E8_SIZE];
s32 gD_8018E118TotalSize;
struct_8018E118_entry D_8018E118[D_8018E118_SIZE];
@@ -1596,6 +1595,7 @@ void func_80092258(void) {
}
}
//! @bug vtx overflow from idx + 36 in this func
void func_80092290(s32 arg0, s32 *arg1, s32 *arg2) {
s32 temp_v1;
s32 i;
@@ -10141,30 +10141,45 @@ escape:
* reasoning on the original author(s) part.
**/
struct_8018D9E0_entry *find_8018D9E0_entry_dupe(s32 arg0) {
struct_8018D9E0_entry *entry = D_8018D9E0;
for (; !(entry > (&D_8018D9E0[D_8018D9E0_SIZE])); entry++) {
if (entry->type == arg0) {
goto escape;
for (size_t i = 0; i < ARRAY_COUNT(D_8018D9E0); i++) {
if (&D_8018D9E0[i].type == arg0) {
return &D_8018D9E0[i];
}
}
return NULL;
// struct_8018D9E0_entry *entry = D_8018D9E0;
// for (; !(entry > (&D_8018D9E0[D_8018D9E0_SIZE])); entry++) {
// if (entry->type == arg0) {
// goto escape;
// }
// }
// Something VERY wrong has occurred
while(true);
escape:
return entry;
// while(true);
//escape:
// return entry;
}
struct_8018D9E0_entry *find_8018D9E0_entry(s32 arg0) {
struct_8018D9E0_entry *entry = D_8018D9E0;
for (; !(entry > (&D_8018D9E0[D_8018D9E0_SIZE])); entry++) {
if (entry->type == arg0) {
goto escape;
for (size_t i = 0; i < ARRAY_COUNT(D_8018D9E0); i++) {
if (&D_8018D9E0[i].type == arg0) {
return &D_8018D9E0[i];
}
}
return NULL;
escape:
return entry;
// struct_8018D9E0_entry *entry = D_8018D9E0;
// for (; !(entry > (&D_8018D9E0[D_8018D9E0_SIZE])); entry++) {
// if (entry->type == arg0) {
// goto escape;
// }
// }
// return NULL;
//escape:
// return entry;
}
s32 func_800AAF70(s32 arg0) {
+2 -2
View File
@@ -59,7 +59,7 @@ typedef struct {
} struct_8018E0E8_entry; //size = 0x8
typedef struct {
/* 0x00 */ u64 *textureData; // This should be interpreted as a segmented address
/* 0x00 */ const char *textureData; // This should be interpreted as a segmented address
/**
* Its hard to tell what exactly what this is meant to be,
* but it appears to be used as some sort of offset/index from the address stored in D_8018D9B0.
@@ -426,7 +426,7 @@ extern s8 D_8018D9D8;
extern s8 D_8018D9D9;
extern struct_8018D9E0_entry D_8018D9E0[D_8018D9E0_SIZE];
extern struct_8018DEE0_entry D_8018DEE0[D_8018DEE0_SIZE];
extern struct_8018E060_entry D_8018E060[D_8018E060_SIZE];
extern struct_8018E060_entry D_8018E060[];
extern struct_8018E0E8_entry D_8018E0E8[D_8018E0E8_SIZE];
extern s32 gD_8018E118TotalSize;
extern struct_8018E118_entry D_8018E118[D_8018E118_SIZE];
+3 -13
View File
@@ -10,17 +10,7 @@
#include "math_util.h"
#include <stdlib.h>
/*** Data ***/
Ambient D_800E8680 = {{
{31, 31, 31}, 0,
{31, 31, 31}, 0,
}};
Light D_800E8688 = {{
{255, 255, 255}, 0,
{255, 255, 255}, 0,
{ 40, 40, 20}, 0,
}};
Lights1 D_800E8680 = gdSPDefLights1(31, 31, 31, 255, 255, 255, 40, 40, 20);
/*** BSS ****/
s16 D_8018EDB0;
@@ -173,8 +163,8 @@ void func_800B0004(void) {
UNUSED u32 pad[0x5];
s32 i, j;
gSPLight(gDisplayListHead++, VIRTUAL_TO_PHYSICAL2(&D_800E8688), LIGHT_1);
gSPLight(gDisplayListHead++, VIRTUAL_TO_PHYSICAL2(&D_800E8680), LIGHT_2);
gSPLight(gDisplayListHead++, VIRTUAL_TO_PHYSICAL2(&D_800E8680.l[0]), LIGHT_1);
gSPLight(gDisplayListHead++, VIRTUAL_TO_PHYSICAL2(&D_800E8680.a), LIGHT_2);
gSPNumLights(gDisplayListHead++, NUMLIGHTS_1);
gSPSetGeometryMode(gDisplayListHead++, G_SHADE | G_SHADING_SMOOTH);
gDPSetCombineLERP(gDisplayListHead++, PRIMITIVE, 0, SHADE, 0, 0, 0, 0, SHADE, PRIMITIVE, 0, SHADE, 0, 0, 0, 0, SHADE);