From eac1d825f2200d01f413e48af37ff80f3c22834e Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 25 Sep 2016 18:37:24 +0300 Subject: [PATCH] Fix a bug binding menu command to a default object class character Due to a wrong looping variable, it was possible to bind a menu accelerator key to a default object class. --- src/options.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/options.c b/src/options.c index 6a0a0d10c..ebe189e6e 100644 --- a/src/options.c +++ b/src/options.c @@ -1768,6 +1768,23 @@ char **opp; return FALSE; } +/* Check if character c is illegal as a menu command key */ +boolean +illegal_menu_cmd_key(c) +char c; +{ + if (c == 0 || c == '\r' || c == '\n' || c == '\033' + || c == ' ' || digit(c) || (letter(c) && c != '@')) + return TRUE; + else { /* reject default object class symbols */ + int j; + for (j = 1; j < MAXOCLASSES; j++) + if (c == def_oc_syms[j].sym) + return TRUE; + } + return FALSE; +} + void parseoptions(opts, tinitial, tfrom_file) register char *opts; @@ -3226,22 +3243,11 @@ boolean tinitial, tfrom_file; } else if ((op = string_for_opt(opts, FALSE)) != 0) { int j; char c, op_buf[BUFSZ]; - boolean isbad = FALSE; escapes(op, op_buf); c = *op_buf; - if (c == 0 || c == '\r' || c == '\n' || c == '\033' - || c == ' ' || digit(c) || (letter(c) && c != '@')) - isbad = TRUE; - else /* reject default object class symbols */ - for (j = 1; j < MAXOCLASSES; j++) - if (c == def_oc_syms[i].sym) { - isbad = TRUE; - break; - } - - if (isbad) + if (illegal_menu_cmd_key(c)) badoption(opts); else add_menu_cmd_alias(c, default_menu_cmd_info[i].cmd); -- 2.40.0