]> Savannah Git Hosting - gnulib.git/commitdiff
system-quote: Fix memory overrun bug on native Windows.
authorBruno Haible <bruno@clisp.org>
Mon, 24 Apr 2023 11:56:46 +0000 (13:56 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 24 Apr 2023 11:56:46 +0000 (13:56 +0200)
* lib/system-quote.c (system_quote): Allocate enough space for the
result.

ChangeLog
lib/system-quote.c

index e9c911de8f976fc5b6cf504d8de2694b8dec4e28..a49d18a10e72e9e56ecd435e36356ab8584c634c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-04-24  Bruno Haible  <bruno@clisp.org>
+
+       system-quote: Fix memory overrun bug on native Windows.
+       * lib/system-quote.c (system_quote): Allocate enough space for the
+       result.
+
 2023-04-24  Bruno Haible  <bruno@clisp.org>
 
        unicodeio tests: Avoid test failures on native Windows.
index c08d2dcd53365eee9a961c948db5f16ffe955074..54e891d98e31db4b9c115957492e7e27db3a496d 100644 (file)
@@ -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;