mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-25 19:42:20 +00:00
fix a buffer overflow in smlua_text_utils
This commit is contained in:
parent
849b5ead50
commit
97439fa557
6 changed files with 11 additions and 42 deletions
|
|
@ -91,7 +91,7 @@ override_allowed_functions = {
|
|||
override_disallowed_functions = {
|
||||
"src/audio/external.h": [ " func_" ],
|
||||
"src/engine/math_util.h": [ "atan2f", "vec3s_sub" ],
|
||||
"src/engine/surface_load.h": [ "alloc_surface_poools", "surface_has_force" ],
|
||||
"src/engine/surface_load.h": [ "alloc_surface_pools" ],
|
||||
"src/engine/surface_collision.h": [ " debug_", "f32_find_wall_collision" ],
|
||||
"src/game/mario_actions_airborne.c": [ "^[us]32 act_.*" ],
|
||||
"src/game/mario_actions_automatic.c": [ "^[us]32 act_.*" ],
|
||||
|
|
|
|||
|
|
@ -9181,10 +9181,6 @@ function find_water_level(x, z)
|
|||
-- ...
|
||||
end
|
||||
|
||||
function alloc_surface_pools()
|
||||
-- ...
|
||||
end
|
||||
|
||||
function clear_dynamic_surfaces()
|
||||
-- ...
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5192,24 +5192,6 @@
|
|||
<br />
|
||||
|
||||
|
||||
## [alloc_surface_pools](#alloc_surface_pools)
|
||||
|
||||
### Lua Example
|
||||
`alloc_surface_pools()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void alloc_surface_pools(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [clear_dynamic_surfaces](#clear_dynamic_surfaces)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
|||
|
|
@ -1918,7 +1918,6 @@
|
|||
<br />
|
||||
|
||||
- surface_load.h
|
||||
- [alloc_surface_pools](functions-5.md#alloc_surface_pools)
|
||||
- [clear_dynamic_surfaces](functions-5.md#clear_dynamic_surfaces)
|
||||
- [get_area_terrain_size](functions-5.md#get_area_terrain_size)
|
||||
- [load_area_terrain](functions-5.md#load_area_terrain)
|
||||
|
|
|
|||
|
|
@ -33288,21 +33288,6 @@ int smlua_func_find_water_level(lua_State* L) {
|
|||
// surface_load.h //
|
||||
////////////////////
|
||||
|
||||
int smlua_func_alloc_surface_pools(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 0) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "alloc_surface_pools", 0, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
alloc_surface_pools();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_clear_dynamic_surfaces(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
|
@ -35233,7 +35218,6 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "find_water_level", smlua_func_find_water_level);
|
||||
|
||||
// surface_load.h
|
||||
smlua_bind_function(L, "alloc_surface_pools", smlua_func_alloc_surface_pools);
|
||||
smlua_bind_function(L, "clear_dynamic_surfaces", smlua_func_clear_dynamic_surfaces);
|
||||
smlua_bind_function(L, "get_area_terrain_size", smlua_func_get_area_terrain_size);
|
||||
smlua_bind_function(L, "load_area_terrain", smlua_func_load_area_terrain);
|
||||
|
|
|
|||
|
|
@ -77,6 +77,14 @@ static u8* smlua_text_utils_convert(const char* str) {
|
|||
return dialogStr;
|
||||
}
|
||||
|
||||
// Checks the first 3 characters
|
||||
static bool str_starts_with_spaces(const char* str) {
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if (str[i] != ' ') { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void smlua_text_utils_reset_all(void) {
|
||||
void **dialogTable = NULL;
|
||||
void **actNameTbl = NULL;
|
||||
|
|
@ -198,7 +206,7 @@ void smlua_text_utils_dialog_replace(enum DialogId dialogId, UNUSED u32 unused,
|
|||
void smlua_text_utils_course_acts_replace(s16 courseNum, const char* courseName, const char* act1, const char* act2, const char* act3, const char* act4, const char* act5, const char* act6) {
|
||||
if (courseNum <= 0 || courseNum > COURSE_RR) { return; }
|
||||
struct CourseName* courseActNames = gReplacedActNameTable[courseNum];
|
||||
snprintf(courseActNames->name, 256, "%s", courseName + 3);
|
||||
snprintf(courseActNames->name, 256, "%s", courseName + (3 * str_starts_with_spaces(courseName)));
|
||||
courseActNames->modIndex = gLuaActiveMod->index;
|
||||
|
||||
#define REPLACE_ACT_NAME(i) \
|
||||
|
|
@ -286,7 +294,7 @@ void smlua_text_utils_secret_star_replace(s16 courseNum, const char* courseName)
|
|||
*/
|
||||
|
||||
struct CourseName* courseActNames = gReplacedActNameTable[courseNum];
|
||||
snprintf(courseActNames->name, 256, "%s", courseName + 3);
|
||||
snprintf(courseActNames->name, 256, "%s", courseName + (3 * str_starts_with_spaces(courseName)));
|
||||
courseActNames->modIndex = gLuaActiveMod->index;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue