aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-12-25 09:01:19 +0000
committerRon Yorston <rmy@pobox.com>2023-12-25 09:01:19 +0000
commit9d619a83a479f6760cdfcadcc0fd0ef1bd110e39 (patch)
treee403d8fc1370cb1494b927ab32d1bda7fa6c2b4f
parent628e1ab2b3af4e9a0d4f8331e20c970db5eba150 (diff)
downloadbusybox-w32-9d619a83a479f6760cdfcadcc0fd0ef1bd110e39.tar.gz
busybox-w32-9d619a83a479f6760cdfcadcc0fd0ef1bd110e39.tar.bz2
busybox-w32-9d619a83a479f6760cdfcadcc0fd0ef1bd110e39.zip
ash: avoid crash when job table is empty
Commit 7b692ddf0 (ash: improved support for jobs built-in) didn't correctly initialise the pointer to the job table if it was empty. This resulted in the following crashing: sh -c "cat <(echo HelloWorld | rev)" Fix forkshell_copy() so the job table pointer is NULL if there are no jobs. Adds 16 bytes. (GitHub issue #379)
-rw-r--r--shell/ash.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c
index d81d27d25..8b7c6c627 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -17058,12 +17058,14 @@ forkshell_copy(struct forkshell *fs, struct forkshell *new)
17058 } 17058 }
17059#endif 17059#endif
17060#if JOBS_WIN32 17060#if JOBS_WIN32
17061 new->jobtab = jobtab_copy(); 17061 if (njobs) {
17062 SAVE_PTR(new->jobtab, "jobtab", NO_FREE); 17062 new->jobtab = jobtab_copy();
17063 new->njobs = njobs; 17063 SAVE_PTR(new->jobtab, "jobtab", NO_FREE);
17064 if (curjob) { 17064 new->njobs = njobs;
17065 new->curjob = new->jobtab + (curjob - jobtab); 17065 if (curjob) {
17066 SAVE_PTR(new->curjob, "curjob", NO_FREE); 17066 new->curjob = new->jobtab + (curjob - jobtab);
17067 SAVE_PTR(new->curjob, "curjob", NO_FREE);
17068 }
17067 } 17069 }
17068#endif 17070#endif
17069 } 17071 }