rcfile: reject key names that are wrong or too long

Meta keys should have a dash as second character, and apart from ^Space
and M-Space key names should be at most two or three characters long.

This fixes https://savannah.gnu.org/bugs/?44688.

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
master
Rishabh Dave 2016-09-14 17:19:53 +05:30 committed by Benno Schulenberg
parent 97f6ae5267
commit e2027aee15
1 changed files with 5 additions and 1 deletions

View File

@ -399,7 +399,11 @@ void parse_binding(char *ptr, bool dobind)
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
goto free_copy;
} else if (keycopy[0] == '^' && (keycopy[1] < 64 || keycopy[1] > 127)) {
} else if ((keycopy[0] == 'M' && keycopy[1] != '-') ||
(keycopy[0] == '^' && ((keycopy[1] < 64 || keycopy[1] > 127) ||
(strlen(keycopy) > 2 && strcmp(keycopy, "^Space") != 0))) ||
(strlen(keycopy) > 3 && strcmp(keycopy, "^Space") != 0 &&
strcmp(keycopy, "M-Space") != 0)) {
rcfile_error(N_("Key name %s is invalid"), keycopy);
goto free_copy;
}