PRVM: string whitespace checking is overly strict
This issue was reported on matrix by Jiān. I'm filing it against DP because it seems excessive to abort a QC VM when a command includes a spurious space.
[ 1 ]- Normal string and eval operation:
]rpn "100" eval
rpn: still on stack: 100
[ 2 ]- String with leading space and eval:
]rpn " 100" eval
Menu_Error: menu: Bad string
QuakeC crash report for menu:
s12230: ./common/command/rpn.qc:551: STORE_S GLOBAL1, GLOBAL16687
s12231: ./common/command/rpn.qc:552: STORE_S GLOBAL16687, GLOBAL4
s12232: ./common/command/rpn.qc:552: CALL1 tokenize_console (=tokenize_console())
s12233: ./common/command/rpn.qc:552: STORE_F GLOBAL1, GLOBAL16686
s12234: ./common/command/rpn.qc:553: STORE_F GLOBAL7221, GLOBAL16691
s12235: ./common/command/rpn.qc:546: GOTO , statement 12216
s12236: ./common/command/rpn.qc:555: STORE_S GLOBAL16685, GLOBAL4
s12237: ./common/command/rpn.qc:555: CALL1 cvar_string (=cvar_string())
./common/command/rpn.qc:555 : GenericCommand_rpn : statement 1658
lib/_all.inc:543 : genericcommand_rpn_m_invokecmd : statement 3
lib/_all.inc:556 : GenericCommand_macro_command : statement 21
lib/_all.inc:596 : GenericCommand : statement 5
./menu/command/menu_cmd.qc:64 : GameCommand : statement 137
Falling back to normal menu
[ 3 ]- String with leading space and set operation:
]rpn " 100 2" "2" intersection
Menu_Error: menu: Bad string
QuakeC crash report for menu:
s12230: ./common/command/rpn.qc:551: STORE_S GLOBAL1, GLOBAL16687
s12231: ./common/command/rpn.qc:552: STORE_S GLOBAL16687, GLOBAL4
s12232: ./common/command/rpn.qc:552: CALL1 tokenize_console (=tokenize_console())
s12233: ./common/command/rpn.qc:552: STORE_F GLOBAL1, GLOBAL16686
s12234: ./common/command/rpn.qc:553: STORE_F GLOBAL7221, GLOBAL16691
s12235: ./common/command/rpn.qc:546: GOTO , statement 12216
s12236: ./common/command/rpn.qc:555: STORE_S GLOBAL16685, GLOBAL4
s12237: ./common/command/rpn.qc:555: CALL1 cvar_string (=cvar_string())
./common/command/rpn.qc:555 : GenericCommand_rpn : statement 1658
lib/_all.inc:543 : genericcommand_rpn_m_invokecmd : statement 3
lib/_all.inc:556 : GenericCommand_macro_command : statement 21
lib/_all.inc:596 : GenericCommand : statement 5
./menu/command/menu_cmd.qc:64 : GameCommand : statement 137
Falling back to normal menu
terencehill: This function is executed when VM_cvar_string is called:
void VM_CheckEmptyString(prvm_prog_t *prog, const char *s)
{
if (ISWHITESPACE(s[0]))
prog->error_cmd("%s: Bad string", prog->name);
}
Any command that reads a cvar name from input has this issue, for example addtolist " " crashes the menu too
bones_was_here: autocvars are protected while in use but other non-engine cvars can be deleted at any time so i think when they don't exist i'd return "" or 0 (from cvar_string() and cvar() ) if i was implementing from scratch
and print a warning when a cvar " aaa" doesn't exist instead of crashing