]> 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>
Thu, 27 Apr 2023 16:33:19 +0000 (18:33 +0200)
* lib/system-quote.c (system_quote): Allocate enough space for the
result.

ChangeLog
lib/system-quote.c

index 700dcd21a2deb29382bcd75d4436044272c68783..45453503f905b8e3b5c5f86e056bba150306f437 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 7ac844830daf8e34555100040ed603f684453bab..bfb93a1454687a23c52432388974d3a31c4ff015 100644 (file)
@@ -1,5 +1,5 @@
 /* Quoting for a system command.
-   Copyright (C) 2012-2022 Free Software Foundation, Inc.
+   Copyright (C) 2012-2023 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2012.
 
    This program is free software: you can redistribute it and/or modify
@@ -258,7 +258,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;