tweaks: check earlier on for sufficient length of the sequence

This commit is contained in:
Benno Schulenberg 2016-07-28 21:27:45 +02:00
parent e3dbffc9f7
commit 6d6f5bd4a7

View File

@ -668,13 +668,10 @@ int convert_sequence(const int *seq, size_t seq_len)
case 'O': case 'O':
switch (seq[1]) { switch (seq[1]) {
case '1': case '1':
if (seq_len >= 3) { if (seq_len > 4 && seq[2] == ';') {
switch (seq[2]) {
case ';':
if (seq_len >= 4) {
switch (seq[3]) { switch (seq[3]) {
case '2': case '2':
if (seq_len >= 5) {
switch (seq[4]) { switch (seq[4]) {
case 'A': /* Esc O 1 ; 2 A == Shift-Up on case 'A': /* Esc O 1 ; 2 A == Shift-Up on
* Terminal. */ * Terminal. */
@ -694,10 +691,8 @@ int convert_sequence(const int *seq, size_t seq_len)
case 'S': /* Esc O 1 ; 2 S == F16 on Terminal. */ case 'S': /* Esc O 1 ; 2 S == F16 on Terminal. */
return KEY_F(16); return KEY_F(16);
} }
}
break; break;
case '5': case '5':
if (seq_len >= 5) {
switch (seq[4]) { switch (seq[4]) {
case 'A': /* Esc O 1 ; 5 A == Ctrl-Up on Terminal. */ case 'A': /* Esc O 1 ; 5 A == Ctrl-Up on Terminal. */
return CONTROL_UP; return CONTROL_UP;
@ -708,12 +703,9 @@ int convert_sequence(const int *seq, size_t seq_len)
case 'D': /* Esc O 1 ; 5 D == Ctrl-Left on Terminal. */ case 'D': /* Esc O 1 ; 5 D == Ctrl-Left on Terminal. */
return CONTROL_LEFT; return CONTROL_LEFT;
} }
}
break; break;
} }
}
break;
}
} }
break; break;
case '2': case '2':