Fix possible buffer overflow in M_TextInputSetString when string length is greatter than buffer length

This commit is contained in:
Indev 2025-10-21 01:46:29 +03:00 committed by NepDisk
parent 1a33deff34
commit 3c7b01cd93

View file

@ -228,8 +228,8 @@ void M_TextInputClear(textinput_t *input)
void M_TextInputSetString(textinput_t *input, const char *c)
{
memset(input->buffer, 0, input->buffer_size);
strcpy(input->buffer, c);
input->cursor = input->select = input->length = strlen(c);
strncpy(input->buffer, c, input->buffer_size);
input->cursor = input->select = input->length = strlen(input->buffer);
}
static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emotes)