[bugfix] zxbox unsupported files crash OOB access to extension list

invalid files return -1 but thats not checked before accessing
invalid array position

Change-Id: Ic07cca250e2584e2e95fa7c41085b254f94ad591
This commit is contained in:
William Wilgus 2026-03-08 11:26:12 -04:00
parent 7d88ab4ef4
commit 4503d63ec8

View file

@ -106,9 +106,13 @@ static int find_extension(const char *ext)
void spcf_read_command_line(const void* parameter)
{
int ix;
ix = find_extension( parameter - 3 + rb->strlen (parameter) );
const char *ext = rb->strrchr(parameter, '.');
ix = (ext ? find_extension(ext+1) : -1);
if (ix < 0)
{
rb->splash(HZ*2, "Invalid extension");
return;
}
file_type = extensions[ix].type;
file_subtype = extensions[ix].subtype;
rb->strlcpy(filenamebuf, parameter, MAXFILENAME - 10 + 1);