public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][Libiberty] Support empty arguments in pex-win32
@ 2016-09-16 15:44 Andrew Stubbs
  2016-09-16 15:48 ` Nick Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Stubbs @ 2016-09-16 15:44 UTC (permalink / raw)
  To: Binutils

[-- Attachment #1: Type: text/plain, Size: 243 bytes --]

Hi,

This patch fixes a libiberty bug in which zero-length arguments to 
"pex_run" subprocesses were silently dropped on MinGW.

Basically, the code does not quote parameters unless it has to, but this 
corner-case was forgotten.

OK?

Andrew

[-- Attachment #2: Support-empty-arguments-in-pex-win32.patch --]
[-- Type: text/x-patch, Size: 2065 bytes --]

From bb184c435ebde5c8cf0e5ecafcefa5f24aadc32d Mon Sep 17 00:00:00 2001
From: Andrew Stubbs <ams@codesourcery.com>
Date: Fri, 16 Sep 2016 16:17:40 +0100
Subject: [PATCH] Support empty arguments in pex-win32

2016-09-16  Andrew Stubbs  <ams@codesourcery.com>

	libiberty/
	* pex-win32.c (argv_to_cmdline): Quote zero-length parameters.

	libiberty/testsuite/
	* test-pexecute.c (main): Insert check for zero-length parameters.
---
 libiberty/pex-win32.c               |  4 ++++
 libiberty/testsuite/test-pexecute.c | 14 ++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c
index 66d2f11..4c15b0d 100644
--- a/libiberty/pex-win32.c
+++ b/libiberty/pex-win32.c
@@ -370,6 +370,8 @@ argv_to_cmdline (char *const *argv)
 	      cmdline_len++;
 	    }
 	}
+      if (j == 0)
+	needs_quotes = 1;
       /* Trailing backslashes also need to be escaped because they will be
          followed by the terminating quote.  */
       if (needs_quotes)
@@ -394,6 +396,8 @@ argv_to_cmdline (char *const *argv)
               break;
             }
         }
+      if (j == 0)
+	needs_quotes = 1;
 
       if (needs_quotes)
         {
diff --git a/libiberty/testsuite/test-pexecute.c b/libiberty/testsuite/test-pexecute.c
index 8e01fda..f62239d 100644
--- a/libiberty/testsuite/test-pexecute.c
+++ b/libiberty/testsuite/test-pexecute.c
@@ -285,6 +285,20 @@ main (int argc, char **argv)
     ERROR ("echo exit status failed");
   pex_free (pex1);
 
+  /* Check empty parameters don't get lost.  */
+  pex1 = TEST_PEX_INIT (PEX_USE_PIPES, "temp");
+  subargv[1] = "echo";
+  subargv[2] = "foo";
+  subargv[3] = "";
+  subargv[4] = "bar";
+  subargv[5] = NULL;
+  TEST_PEX_RUN (pex1, 0, "./test-pexecute", subargv, NULL, NULL);
+  e = TEST_PEX_READ_OUTPUT (pex1);
+  CHECK_LINE (e, "foo  bar");  /* Two spaces!  */
+  if (TEST_PEX_GET_STATUS_1 (pex1) != 0)
+    ERROR ("echo exit status failed");
+  pex_free (pex1);
+
   pex1 = TEST_PEX_INIT (PEX_USE_PIPES, "temp");
   subargv[1] = "echo";
   subargv[2] = "bar";
-- 
1.8.1.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][Libiberty] Support empty arguments in pex-win32
  2016-09-16 15:44 [PATCH][Libiberty] Support empty arguments in pex-win32 Andrew Stubbs
@ 2016-09-16 15:48 ` Nick Clifton
  2016-09-16 15:59   ` Andrew Stubbs
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2016-09-16 15:48 UTC (permalink / raw)
  To: Andrew Stubbs, Binutils

Hi Andrew,

> This patch fixes a libiberty bug

Sorry - but the libiberty sources are maintained as part of the GCC project
not the binutils project.  (Although the sources are used by both projects).
Please could you resubmit your bug report and patch to gcc-patches@gcc.gnu.org.
Thanks.

Cheers
  Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][Libiberty] Support empty arguments in pex-win32
  2016-09-16 15:48 ` Nick Clifton
@ 2016-09-16 15:59   ` Andrew Stubbs
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Stubbs @ 2016-09-16 15:59 UTC (permalink / raw)
  To: Nick Clifton, Andrew Stubbs, Binutils

On 16/09/16 16:48, Nick Clifton wrote:
> Sorry - but the libiberty sources are maintained as part of the GCC project
> not the binutils project.  (Although the sources are used by both projects).
> Please could you resubmit your bug report and patch to gcc-patches@gcc.gnu.org.
> Thanks.

Sorry, I knew it was one of them.

Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-16 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16 15:44 [PATCH][Libiberty] Support empty arguments in pex-win32 Andrew Stubbs
2016-09-16 15:48 ` Nick Clifton
2016-09-16 15:59   ` Andrew Stubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).