* tests/test-mcel.c (main): Don’t overrun test input buffer.
Problem reported by Bruno Haible; found on CHERI-64.
---
 ChangeLog         | 6 ++++++
 tests/test-mcel.c | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bc9ed2e489..d322f9a08e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-11-06  Paul Eggert  <egg...@cs.ucla.edu>
+
+       mcel-tests: fix read overrun in test case
+       * tests/test-mcel.c (main): Don’t overrun test input buffer.
+       Problem reported by Bruno Haible; found on CHERI-64.
+
 2023-11-06  Bruno Haible  <br...@clisp.org>
 
        fenv-exceptions-tracking-c99 tests: Fix typo.
diff --git a/tests/test-mcel.c b/tests/test-mcel.c
index 2977ec06a0..238a512db1 100644
--- a/tests/test-mcel.c
+++ b/tests/test-mcel.c
@@ -123,9 +123,10 @@ main (void)
           for (int ti = 0; ti < sizeof terminator; ti++)
             {
               char t = terminator[ti];
-              if (i == t)
+              if (i == t || j == t || k == t)
                 continue;
-              mcel_t d = mcel_scant (ijk, t);
+              char const ijkt[] = {i, j, k, t};
+              mcel_t d = mcel_scant (ijkt, t);
               ASSERT (c.ch == d.ch && c.err == d.err && c.len == d.len);
               if (!t)
                 {
-- 
2.41.0


Reply via email to