Enforce limits in player settings packet to prevent possible crash
This commit is contained in:
parent
ac99e240a6
commit
63c4827082
|
@ -4,6 +4,8 @@
|
|||
#include "types.h"
|
||||
// NOTE: do not include any additional headers
|
||||
|
||||
#define PALETTE_MAX 24
|
||||
|
||||
enum CharacterType {
|
||||
CT_MARIO,
|
||||
CT_LUIGI,
|
||||
|
|
|
@ -85,7 +85,7 @@ struct GraphNodeObject gMirrorMario[MAX_PLAYERS]; // copy of Mario's geo node f
|
|||
gdSPDefLights1((pr >> 1), (pg >> 1), (pb >> 1), pr, pg, pb, 0x28, 0x28, 0x28), \
|
||||
}
|
||||
|
||||
struct PlayerColor gPlayerColors[] = {
|
||||
struct PlayerColor gPlayerColors[PALETTE_MAX] = {
|
||||
// default mario
|
||||
DEFINE_PLAYER_COLOR(0xff, 0x00, 0x00, /**/ 0x00, 0x00, 0xff),
|
||||
// default luigi
|
||||
|
|
|
@ -91,7 +91,7 @@ void djui_panel_player_create(struct DjuiBase* caller) {
|
|||
djui_base_set_size(&selectionbox1->base, 1.0f, 32);
|
||||
djui_interactable_hook_value_change(&selectionbox1->base, djui_panel_player_value_changed);
|
||||
|
||||
char* paletteChoices[24] = {
|
||||
char* paletteChoices[PALETTE_MAX] = {
|
||||
"Mario",
|
||||
"Luigi",
|
||||
"Waluigi",
|
||||
|
@ -117,7 +117,7 @@ void djui_panel_player_create(struct DjuiBase* caller) {
|
|||
"Fire Waluigi",
|
||||
"Fire Wario",
|
||||
};
|
||||
struct DjuiSelectionbox* selectionbox2 = djui_selectionbox_create(&body->base, "Palette", paletteChoices, 24, &configPlayerPalette);
|
||||
struct DjuiSelectionbox* selectionbox2 = djui_selectionbox_create(&body->base, "Palette", paletteChoices, PALETTE_MAX, &configPlayerPalette);
|
||||
djui_base_set_size_type(&selectionbox2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&selectionbox2->base, 1.0f, 32);
|
||||
djui_interactable_hook_value_change(&selectionbox2->base, djui_panel_player_value_changed);
|
||||
|
|
|
@ -42,6 +42,10 @@ void network_receive_player_settings(struct Packet* p) {
|
|||
return;
|
||||
}
|
||||
|
||||
// sanity check
|
||||
if (playerModel >= CT_MAX) { playerModel = CT_MARIO; }
|
||||
if (playerPalette >= PALETTE_MAX) { playerPalette = 0; }
|
||||
|
||||
struct NetworkPlayer* np = network_player_from_global_index(globalId);
|
||||
snprintf(np->name, MAX_PLAYER_STRING, "%s", playerName);
|
||||
np->modelIndex = playerModel;
|
||||
|
|
|
@ -224,7 +224,7 @@ void main_func(void) {
|
|||
mod_list_init();
|
||||
configfile_load(configfile_name());
|
||||
if (configPlayerModel >= CT_MAX) { configPlayerModel = 0; }
|
||||
if (configPlayerPalette >= 24) { configPlayerPalette = 0; }
|
||||
if (configPlayerPalette >= PALETTE_MAX) { configPlayerPalette = 0; }
|
||||
|
||||
if (gCLIOpts.FullScreen == 1)
|
||||
configWindow.fullscreen = true;
|
||||
|
|
Loading…
Reference in New Issue