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