OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
3.0 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../make/make-3.82-0006-construct-command-line.patch
  5. # Copyright (C) 2012 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 12e4f0b3019ddd621147358500e87b91ac6361cf Mon Sep 17 00:00:00 2001
  17. From: Christian Wiese <chris@opensde.org>
  18. Date: Mon, 22 Oct 2012 18:03:56 +0200
  19. Subject: [PATCH] construct command line
  20. ChangeLog:
  21. 2011-05-07 Eli Zaretskii <eliz@gnu.org>
  22. * job.c (construct_command_argv_internal): Don't assume shellflags
  23. is always non-NULL. Escape-protect characters special to the
  24. shell when copying the value of SHELL into new_line. Fixes
  25. Savannah bug #23922.
  26. ---
  27. job.c | 23 ++++++++++++++++-------
  28. 1 files changed, 16 insertions(+), 7 deletions(-)
  29. diff --git a/job.c b/job.c
  30. index aacfb84..535a751 100644
  31. --- a/job.c
  32. +++ b/job.c
  33. @@ -2792,12 +2792,12 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
  34. unsigned int shell_len = strlen (shell);
  35. unsigned int line_len = strlen (line);
  36. - unsigned int sflags_len = strlen (shellflags);
  37. + unsigned int sflags_len = shellflags ? strlen (shellflags) : 0;
  38. char *command_ptr = NULL; /* used for batch_mode_shell mode */
  39. char *new_line;
  40. # ifdef __EMX__ /* is this necessary? */
  41. - if (!unixy_shell)
  42. + if (!unixy_shell && shellflags)
  43. shellflags[0] = '/'; /* "/c" */
  44. # endif
  45. @@ -2859,19 +2859,28 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
  46. new_argv = xmalloc (4 * sizeof (char *));
  47. new_argv[0] = xstrdup(shell);
  48. - new_argv[1] = xstrdup(shellflags);
  49. + new_argv[1] = xstrdup(shellflags ? shellflags : "");
  50. new_argv[2] = line;
  51. new_argv[3] = NULL;
  52. return new_argv;
  53. }
  54. - new_line = alloca (shell_len + 1 + sflags_len + 1
  55. + new_line = alloca ((shell_len*2) + 1 + sflags_len + 1
  56. + (line_len*2) + 1);
  57. ap = new_line;
  58. - memcpy (ap, shell, shell_len);
  59. - ap += shell_len;
  60. + /* Copy SHELL, escaping any characters special to the shell. If
  61. + we don't escape them, construct_command_argv_internal will
  62. + recursively call itself ad nauseam, or until stack overflow,
  63. + whichever happens first. */
  64. + for (p = shell; *p != '\0'; ++p)
  65. + {
  66. + if (strchr (sh_chars, *p) != 0)
  67. + *(ap++) = '\\';
  68. + *(ap++) = *p;
  69. + }
  70. *(ap++) = ' ';
  71. - memcpy (ap, shellflags, sflags_len);
  72. + if (shellflags)
  73. + memcpy (ap, shellflags, sflags_len);
  74. ap += sflags_len;
  75. *(ap++) = ' ';
  76. command_ptr = ap;
  77. --
  78. 1.7.2.3