mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 11:10:39 +00:00
Make sure I_EnterText never writes a null terminator out of bounds.
git-svn-id: https://svn.eduke32.com/eduke32@6530 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4313460da7
commit
d722b998ed
3 changed files with 11 additions and 9 deletions
|
@ -3179,7 +3179,7 @@ static int32_t Menu_EntryStringSubmit(MenuEntry_t *entry, char *input)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ud.savegame[M_SAVE.currentEntry][MAXSAVEGAMENAME] = 0;
|
ud.savegame[M_SAVE.currentEntry][MAXSAVEGAMENAME] = 0;
|
||||||
Bstrncpy(object->variable, input, object->maxlength);
|
Bstrncpy(object->variable, input, object->bufsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_SavePlayerMaybeMulti(M_SAVE.currentEntry);
|
G_SavePlayerMaybeMulti(M_SAVE.currentEntry);
|
||||||
|
@ -5648,8 +5648,8 @@ static void Menu_RunInput_EntryString_Activate(MenuEntry_t *entry)
|
||||||
object->editfield = typebuf;
|
object->editfield = typebuf;
|
||||||
|
|
||||||
// this limitation is an arbitrary implementation detail
|
// this limitation is an arbitrary implementation detail
|
||||||
if (object->maxlength > TYPEBUFSIZE)
|
if (object->bufsize > TYPEBUFSIZE)
|
||||||
object->maxlength = TYPEBUFSIZE;
|
object->bufsize = TYPEBUFSIZE;
|
||||||
|
|
||||||
Menu_EntryStringActivate(/*entry*/);
|
Menu_EntryStringActivate(/*entry*/);
|
||||||
WithSDL2_StartTextInput();
|
WithSDL2_StartTextInput();
|
||||||
|
@ -5658,7 +5658,7 @@ static void Menu_RunInput_EntryString_Activate(MenuEntry_t *entry)
|
||||||
static void Menu_RunInput_EntryString_Submit(MenuEntry_t *entry, MenuString_t *object)
|
static void Menu_RunInput_EntryString_Submit(MenuEntry_t *entry, MenuString_t *object)
|
||||||
{
|
{
|
||||||
if (!Menu_EntryStringSubmit(entry, object->editfield))
|
if (!Menu_EntryStringSubmit(entry, object->editfield))
|
||||||
Bstrncpy(object->variable, object->editfield, object->maxlength);
|
Bstrncpy(object->variable, object->editfield, object->bufsize);
|
||||||
|
|
||||||
object->editfield = NULL;
|
object->editfield = NULL;
|
||||||
WithSDL2_StopTextInput();
|
WithSDL2_StopTextInput();
|
||||||
|
@ -5784,7 +5784,7 @@ static void Menu_RunInput(Menu_t *cm)
|
||||||
case TextForm:
|
case TextForm:
|
||||||
{
|
{
|
||||||
MenuTextForm_t *object = (MenuTextForm_t*)cm->object;
|
MenuTextForm_t *object = (MenuTextForm_t*)cm->object;
|
||||||
int32_t hitstate = I_EnterText(object->input, object->maxlength, 0);
|
int32_t hitstate = I_EnterText(object->input, object->bufsize-1, 0);
|
||||||
|
|
||||||
if (hitstate == -1 || Menu_RunInput_MouseReturn())
|
if (hitstate == -1 || Menu_RunInput_MouseReturn())
|
||||||
{
|
{
|
||||||
|
@ -6250,7 +6250,7 @@ static void Menu_RunInput(Menu_t *cm)
|
||||||
{
|
{
|
||||||
MenuString_t *object = (MenuString_t*)currentry->entry;
|
MenuString_t *object = (MenuString_t*)currentry->entry;
|
||||||
|
|
||||||
int32_t hitstate = I_EnterText(object->editfield, object->maxlength, object->flags);
|
int32_t hitstate = I_EnterText(object->editfield, object->bufsize-1, object->flags);
|
||||||
|
|
||||||
if (hitstate == -1 || Menu_RunInput_MouseReturn())
|
if (hitstate == -1 || Menu_RunInput_MouseReturn())
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,7 +295,7 @@ typedef struct MenuString_t
|
||||||
MenuFont_t *font;
|
MenuFont_t *font;
|
||||||
|
|
||||||
// effect
|
// effect
|
||||||
int32_t maxlength;
|
int32_t bufsize;
|
||||||
int32_t flags;
|
int32_t flags;
|
||||||
} MenuString_t;
|
} MenuString_t;
|
||||||
typedef struct MenuSpacer_t
|
typedef struct MenuSpacer_t
|
||||||
|
@ -392,7 +392,7 @@ typedef struct MenuTextForm_t
|
||||||
|
|
||||||
// traits
|
// traits
|
||||||
const char *instructions;
|
const char *instructions;
|
||||||
int32_t maxlength;
|
int32_t bufsize;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
} MenuTextForm_t;
|
} MenuTextForm_t;
|
||||||
typedef struct MenuFileSelect_t
|
typedef struct MenuFileSelect_t
|
||||||
|
|
|
@ -1812,7 +1812,9 @@ void Net_SendMessage(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int32_t const hitstate = I_EnterText(typebuf, 120, 0);
|
#define MAXCHATLENGTH 120
|
||||||
|
EDUKE32_STATIC_ASSERT(MAXCHATLENGTH < TYPEBUFSIZE);
|
||||||
|
int32_t const hitstate = I_EnterText(typebuf, MAXCHATLENGTH, 0);
|
||||||
|
|
||||||
int32_t const y = ud.screen_size > 1 ? (200-58)<<16 : (200-35)<<16;
|
int32_t const y = ud.screen_size > 1 ? (200-58)<<16 : (200-35)<<16;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue