[bugfix, AS] zxbox keyboard input overflows text variable

int zx_kbd_input(char* text/*, int buflen*/)
is supplied with a single char by all callers
thats fine till we get to here in the decode routine
while (*utf8)

since it just reads till it hits a 0 its probably fine
but Address Sanitizer caught it

make c a char array of 8 bytes to ensure a NULL

Change-Id: Iad3284df34cb7451422fc96ae0bb8e159ee440b0
This commit is contained in:
William Wilgus 2026-03-05 01:05:34 -05:00
parent cef29a1986
commit 086c29267c

View file

@ -133,7 +133,7 @@ int spcf_read_conf_file(const char *filename)
/* set keys */
static void set_keys(void){
char c;
char c[8] = {0};
int selected=0;
int result;
int menu_quit=0;
@ -151,31 +151,31 @@ static void set_keys(void){
case 0:
if (!zx_kbd_input((char*) &c))
{
settings.keymap[0]=c;
settings.keymap[0]=c[0];
}
break;
case 1:
if (!zx_kbd_input((char*) &c))
{
settings.keymap[1]=c;
settings.keymap[1]=c[0];
}
break;
case 2:
if (!zx_kbd_input((char*) &c))
{
settings.keymap[2]=c;
settings.keymap[2]=c[0];
}
break;
case 3:
if (!zx_kbd_input((char*) &c))
{
settings.keymap[3]=c;
settings.keymap[3]=c[0];
}
break;
case 4:
if (!zx_kbd_input((char*) &c))
{
settings.keymap[4]=c;
settings.keymap[4]=c[0];
}
break;
default:
@ -320,7 +320,7 @@ static bool zxbox_menu(void)
int result;
int menu_quit=0;
int exit=0;
char c;
char c[8] = {0};
MENUITEM_STRINGLIST(menu, "ZXBox", NULL,
"VKeyboard", "Play/Pause Tape",
"Save quick snapshot", "Load quick snapshot",
@ -338,7 +338,7 @@ static bool zxbox_menu(void)
case 0:
if (!zx_kbd_input((char*) &c))
{
press_key(c);
press_key(c[0]);
}
clear_kbd=1;
menu_quit=1;