[vte] parser: Ignore sequence with too many parameters
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] parser: Ignore sequence with too many parameters
- Date: Tue, 27 Mar 2018 17:47:51 +0000 (UTC)
commit e2bd1889ec229e718a2ad4ccd7c3e2fecfe3d1c8
Author: Christian Persch <chpe src gnome org>
Date: Tue Mar 27 19:40:13 2018 +0200
parser: Ignore sequence with too many parameters
Also ignore sequences with too many default parameters.
src/parser-test.cc | 4 ++--
src/parser.cc | 9 +++++++--
2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/parser-test.cc b/src/parser-test.cc
index f70ba8b..89bdab1 100644
--- a/src/parser-test.cc
+++ b/src/parser-test.cc
@@ -1069,8 +1069,8 @@ test_seq_csi_max(void)
* explicit value, or default, causes the sequence to be ignored.
*/
str.pop_back(); /* erase final character */
- test_seq_csi_max(str, U":"s, VTE_SEQ_CSI);
- test_seq_csi_max(str, U";"s, VTE_SEQ_CSI);
+ test_seq_csi_max(str, U":"s);
+ test_seq_csi_max(str, U";"s);
test_seq_csi_max(str, U":12345"s);
test_seq_csi_max(str, U";12345"s);
test_seq_csi_max(str, U":12345;"s);
diff --git a/src/parser.cc b/src/parser.cc
index 83f2e7d..e1c99d8 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -678,9 +678,14 @@ static void parser_params_overflow(struct vte_parser *parser, uint32_t raw)
STATE_CSI_IGNORE : STATE_DCS_IGNORE);
}
+/* The next two functions are only called when encountering a ';' or ':',
+ * so if there's already MAX-1 parameters, the ';' or ':' would finish
+ * the MAXth parameter and there would be a default or non-default
+ * MAX+1th parameter following it.
+ */
static int parser_finish_param(struct vte_parser *parser, uint32_t raw)
{
- if (G_LIKELY(parser->seq.n_args < VTE_PARSER_ARG_MAX)) {
+ if (G_LIKELY(parser->seq.n_args < VTE_PARSER_ARG_MAX - 1)) {
vte_seq_arg_finish(&parser->seq.args[parser->seq.n_args], false);
++parser->seq.n_args;
++parser->seq.n_final_args;
@@ -692,7 +697,7 @@ static int parser_finish_param(struct vte_parser *parser, uint32_t raw)
static int parser_finish_subparam(struct vte_parser *parser, uint32_t raw)
{
- if (G_LIKELY(parser->seq.n_args < VTE_PARSER_ARG_MAX)) {
+ if (G_LIKELY(parser->seq.n_args < VTE_PARSER_ARG_MAX - 1)) {
vte_seq_arg_finish(&parser->seq.args[parser->seq.n_args], true);
++parser->seq.n_args;
} else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]