This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch tymux-11-parser-speedup
in repository terminology.
View the commit online.
commit 45a0d6a2b07b2bc6a8d2cf9802549cc4649e687a
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 22 14:18:44 2026 -0600
tests: cover CSI argument parsing at the INT32_MAX boundary
The overflow check of _csi_arg_get_subparam() decides on the digit
that would cross INT32_MAX, and nothing tested either side of it.
---
src/bin/termptyesc.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/bin/tytest.c | 1 +
src/bin/unit_tests.h | 1 +
3 files changed, 81 insertions(+)
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index a0291833..bf518d9c 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -4269,6 +4269,85 @@ tytest_osc_arg_get(void)
}
#endif
+#if defined(BINARY_TYTEST)
+/* offset is where *ptr ends up in the input, or -1 for NULL. */
+static int
+_csi_arg_get_check(const char *input, int expected_arg,
+ Eina_Bool expected_sub, int expected_offset,
+ Eina_Bool expected_error)
+{
+ Termpty ty;
+ Eina_Unicode buf[64], *p = buf;
+ Eina_Bool sub;
+ int i;
+
+ memset(&ty, 0, sizeof(ty));
+ for (i = 0; input[i]; i++)
+ buf[i] = input[i];
+ buf[i] = '\0';
+
+ if (_csi_arg_get_subparam(&ty, &p, &sub) != expected_arg)
+ return 0;
+ if (sub != expected_sub)
+ return 0;
+ if (ty.decoding_error != expected_error)
+ return 0;
+ if (expected_offset < 0)
+ return p == NULL;
+ return p == buf + expected_offset;
+}
+
+int
+tytest_csi_arg_get(void)
+{
+ assert(_csi_arg_get_check("0", 0, EINA_FALSE, -1, EINA_FALSE));
+ assert(_csi_arg_get_check("38;2", 38, EINA_FALSE, 3, EINA_FALSE));
+ assert(_csi_arg_get_check("4:3", 4, EINA_TRUE, 2, EINA_FALSE));
+ assert(_csi_arg_get_check("?25", 25, EINA_FALSE, -1, EINA_FALSE));
+ assert(_csi_arg_get_check(">4;1", 4, EINA_FALSE, 3, EINA_FALSE));
+ assert(_csi_arg_get_check(";5", -ESC_ARG_NO_VALUE, EINA_FALSE, 1,
+ EINA_FALSE));
+ assert(_csi_arg_get_check("", -ESC_ARG_NO_VALUE, EINA_FALSE, -1,
+ EINA_FALSE));
+ assert(_csi_arg_get_check("?", -ESC_ARG_NO_VALUE, EINA_FALSE, -1,
+ EINA_FALSE));
+ assert(_csi_arg_get_check("12 ", 12, EINA_FALSE, 2, EINA_FALSE));
+ assert(_csi_arg_get_check("5;", 5, EINA_FALSE, 1, EINA_FALSE));
+
+ /* INT32_MAX is 2147483647: the last digit and the digit count are the
+ * two ways to overflow it. */
+ assert(_csi_arg_get_check("214748364", 214748364, EINA_FALSE, -1,
+ EINA_FALSE));
+ assert(_csi_arg_get_check("2147483646", 2147483646, EINA_FALSE, -1,
+ EINA_FALSE));
+ assert(_csi_arg_get_check("2147483647", INT32_MAX, EINA_FALSE, -1,
+ EINA_FALSE));
+ assert(_csi_arg_get_check("2147483647;1", INT32_MAX, EINA_FALSE, 11,
+ EINA_FALSE));
+ assert(_csi_arg_get_check("2147483648", -ESC_ARG_ERROR, EINA_FALSE, -1,
+ EINA_TRUE));
+ assert(_csi_arg_get_check("2147483649", -ESC_ARG_ERROR, EINA_FALSE, -1,
+ EINA_TRUE));
+ assert(_csi_arg_get_check("2147483650", -ESC_ARG_ERROR, EINA_FALSE, -1,
+ EINA_TRUE));
+ assert(_csi_arg_get_check("2147483657", -ESC_ARG_ERROR, EINA_FALSE, -1,
+ EINA_TRUE));
+ assert(_csi_arg_get_check("2147483700", -ESC_ARG_ERROR, EINA_FALSE, -1,
+ EINA_TRUE));
+ assert(_csi_arg_get_check("2200000000", -ESC_ARG_ERROR, EINA_FALSE, -1,
+ EINA_TRUE));
+ assert(_csi_arg_get_check("3000000000", -ESC_ARG_ERROR, EINA_FALSE, -1,
+ EINA_TRUE));
+ assert(_csi_arg_get_check("21474836470", -ESC_ARG_ERROR, EINA_FALSE, -1,
+ EINA_TRUE));
+ assert(_csi_arg_get_check("99999999999999999999", -ESC_ARG_ERROR,
+ EINA_FALSE, -1, EINA_TRUE));
+ assert(_csi_arg_get_check("0002147483647", INT32_MAX, EINA_FALSE, -1,
+ EINA_FALSE));
+ return 0;
+}
+#endif
+
static int
_eina_unicode_to_hex(Eina_Unicode u)
{
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index ab529ff4..42c574f3 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -172,6 +172,7 @@ static struct {
{ "osc_arg_get", tytest_osc_arg_get},
{ "termpty_log_level", tytest_termpty_log_level},
{ "utf8_decode", tytest_utf8_decode},
+ { "csi_arg_get", tytest_csi_arg_get},
{ "osc_color_reset", tytest_osc_color_reset},
{ "osc_color_name", tytest_osc_color_name},
{ "xterm_parse_color", tytest_xterm_parse_color},
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 5d052c89..15d038db 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -127,6 +127,7 @@ int tytest_ty_escape_max(void);
int tytest_osc_arg_get(void);
int tytest_termpty_log_level(void);
int tytest_utf8_decode(void);
+int tytest_csi_arg_get(void);
int tytest_osc_color_reset(void);
int tytest_osc_color_name(void);
int tytest_xterm_parse_color(void);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.