From ab97e40ca6529f3ede3f4bc2c4eb4c100242d566 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 18 Oct 2016 14:10:01 +0200 Subject: [PATCH] sh-quote, system-quote: revert regression of unit test. * tests/test-sh-quote.c (check_one): Do detect buffer overruns. * tests/test-system-quote-main.c (check_one): Likewise. --- ChangeLog | 8 +++++++- tests/test-sh-quote.c | 2 ++ tests/test-system-quote-main.c | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index df2f429c05..48aa28dae1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,15 @@ +2016-10-18 Bruno Haible + + sh-quote, system-quote: revert regression of unit test. + * tests/test-sh-quote.c (check_one): Do detect buffer overruns. + * tests/test-system-quote-main.c (check_one): Likewise. + 2016-10-16 Pádraig Brady quotearg: fix stale tests * tests/test-quotearg.c [locale_results]: Add the missing str7 entries to the expected results. - tests/test-system-quote-main.c (check_one): Don't enforce that we + * tests/test-system-quote-main.c (check_one): Don't enforce that we don't write beyond the returned length, since that's no longer the case if we switch to a more concise quoting style. * tests/test-sh-quote.c (check_one): Likewise. diff --git a/tests/test-sh-quote.c b/tests/test-sh-quote.c index 091da34566..ff05c8ecfe 100644 --- a/tests/test-sh-quote.c +++ b/tests/test-sh-quote.c @@ -41,9 +41,11 @@ check_one (const char *input, const char *expected) ASSERT (output_len <= sizeof (buf) - 2); memset (buf, '\0', output_len + 1); + buf[output_len + 1] = '%'; bufend = shell_quote_copy (buf, input); ASSERT (bufend == buf + output_len); ASSERT (memcmp (buf, output, output_len + 1) == 0); + ASSERT (buf[output_len + 1] == '%'); ASSERT (strcmp (output, expected) == 0); diff --git a/tests/test-system-quote-main.c b/tests/test-system-quote-main.c index 40d7ec6487..8eb6a17cc9 100644 --- a/tests/test-system-quote-main.c +++ b/tests/test-system-quote-main.c @@ -58,9 +58,11 @@ check_one (enum system_command_interpreter interpreter, const char *prog, ASSERT (output_len <= sizeof (buf) - 2); memset (buf, '\0', output_len + 1); + buf[output_len + 1] = '%'; bufend = system_quote_copy (buf, interpreter, input); ASSERT (bufend == buf + output_len); ASSERT (memcmp (buf, output, output_len + 1) == 0); + ASSERT (buf[output_len + 1] == '%'); /* Store INPUT in EXPECTED_DATA_FILE, for verification by the child process. */ -- 2.39.5