On native Windows, I sometimes see the test-system-quote.sh test fail,
with exit code 127 and no other details.

The cause is a memory overrun bug, present since the beginning of this module.

This patch fixes it.


2023-04-24  Bruno Haible  <br...@clisp.org>

        system-quote: Fix memory overrun bug on native Windows.
        * lib/system-quote.c (system_quote): Allocate enough space for the
        result.

diff --git a/lib/system-quote.c b/lib/system-quote.c
index c08d2dcd53..54e891d98e 100644
--- a/lib/system-quote.c
+++ b/lib/system-quote.c
@@ -257,7 +257,7 @@ system_quote (enum system_command_interpreter interpreter,
     case SCI_SYSTEM:
     case SCI_WINDOWS_CMD:
       {
-        size_t length = system_quote_length (interpreter, string);
+        size_t length = system_quote_length (interpreter, string) + 1;
         char *quoted = XNMALLOC (length, char);
         system_quote_copy (quoted, interpreter, string);
         return quoted;




Reply via email to