make-3.82-long-command-line.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. https://savannah.gnu.org/bugs/?36451
  2. From a95796de3a491d8acfc8ea94c217b90531161786 Mon Sep 17 00:00:00 2001
  3. From: psmith <psmith>
  4. Date: Sun, 9 Sep 2012 23:25:07 +0000
  5. Subject: [PATCH] Keep the command line on the heap to avoid stack overflow.
  6. Fixes Savannah bug #36451.
  7. ---
  8. ChangeLog | 3 +++
  9. job.c | 13 +++++++++----
  10. 2 files changed, 12 insertions(+), 4 deletions(-)
  11. diff --git a/job.c b/job.c
  12. index 754576b..f7b7d51 100644
  13. --- a/job.c
  14. +++ b/job.c
  15. @@ -2984,8 +2984,8 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
  16. return new_argv;
  17. }
  18. - new_line = alloca ((shell_len*2) + 1 + sflags_len + 1
  19. - + (line_len*2) + 1);
  20. + new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1
  21. + + (line_len*2) + 1);
  22. ap = new_line;
  23. /* Copy SHELL, escaping any characters special to the shell. If
  24. we don't escape them, construct_command_argv_internal will
  25. @@ -3052,8 +3052,11 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
  26. *ap++ = *p;
  27. }
  28. if (ap == new_line + shell_len + sflags_len + 2)
  29. - /* Line was empty. */
  30. - return 0;
  31. + {
  32. + /* Line was empty. */
  33. + free (new_line);
  34. + return 0;
  35. + }
  36. *ap = '\0';
  37. #ifdef WINDOWS32
  38. @@ -3194,6 +3197,8 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
  39. fatal (NILF, _("%s (line %d) Bad shell context (!unixy && !batch_mode_shell)\n"),
  40. __FILE__, __LINE__);
  41. #endif
  42. +
  43. + free (new_line);
  44. }
  45. #endif /* ! AMIGA */
  46. --
  47. 1.7.12