Skip to content
Snippets Groups Projects
Commit d76e21b5 authored by Inuyasha's avatar Inuyasha
Browse files

fix bind out of bounds / keystring misreading

parent 732c1a87
No related branches found
No related tags found
No related merge requests found
...@@ -202,7 +202,7 @@ static void CONS_Bind_f(void) ...@@ -202,7 +202,7 @@ static void CONS_Bind_f(void)
} }
key = G_KeyStringtoNum(COM_Argv(1)); key = G_KeyStringtoNum(COM_Argv(1));
if (!key) if (key <= 0 || key >= NUMINPUTS)
{ {
CONS_Alert(CONS_NOTICE, M_GetText("Invalid key name\n")); CONS_Alert(CONS_NOTICE, M_GetText("Invalid key name\n"));
return; return;
......
...@@ -1042,13 +1042,13 @@ INT32 G_KeyStringtoNum(const char *keystr) ...@@ -1042,13 +1042,13 @@ INT32 G_KeyStringtoNum(const char *keystr)
if (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z') if (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z')
return keystr[0]; return keystr[0];
if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9')
return atoi(&keystr[3]);
for (j = 0; j < NUMKEYNAMES; j++) for (j = 0; j < NUMKEYNAMES; j++)
if (!stricmp(keynames[j].name, keystr)) if (!stricmp(keynames[j].name, keystr))
return keynames[j].keynum; return keynames[j].keynum;
if (strlen(keystr) > 3)
return atoi(&keystr[3]);
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment