aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-01-14 11:06:43 +0000
committerRon Yorston <rmy@pobox.com>2024-01-14 11:06:43 +0000
commit19458265b715108bb45f7fc5a7cdb43f9a3be73b (patch)
tree930c2642d92d88c093f6a22e7b5576ff04b1da87 /shell
parent72602d763cd164320a27f6db0fedb490cb9b457f (diff)
downloadbusybox-w32-19458265b715108bb45f7fc5a7cdb43f9a3be73b.tar.gz
busybox-w32-19458265b715108bb45f7fc5a7cdb43f9a3be73b.tar.bz2
busybox-w32-19458265b715108bb45f7fc5a7cdb43f9a3be73b.zip
ash: special case in creation of pipeline
When a pipeline is created the parent allocates an array of procstat structures sufficient for the number of members of the pipeline. The child processes, however, only see the number of processes created so far. Thus, the first child sees that a procstat array has been created but contains no processes. This resulted in an invalid pointer to the procstat array in the first child. This probably doesn't matter: if the number of processes is zero there should be no need to access the array. Set the pointer to NULL so if it is accessed we'll know about it.
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index adab63fa7..e45c8d61d 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -16842,8 +16842,10 @@ jobtab_copy(void)
16842 xasprintf("jobtab[%d].ps0.ps_cmd '%s'", 16842 xasprintf("jobtab[%d].ps0.ps_cmd '%s'",
16843 i, jobtab[i].ps0.ps_cmd), FREE); 16843 i, jobtab[i].ps0.ps_cmd), FREE);
16844 new[i].ps = &new[i].ps0; 16844 new[i].ps = &new[i].ps0;
16845 } else { 16845 } else if (jobtab[i].nprocs) {
16846 new[i].ps = procstat_copy(i); 16846 new[i].ps = procstat_copy(i);
16847 } else {
16848 new[i].ps = NULL;
16847 } 16849 }
16848 SAVE_PTR(new[i].ps, xasprintf("jobtab[%d].ps", i), FREE); 16850 SAVE_PTR(new[i].ps, xasprintf("jobtab[%d].ps", i), FREE);
16849 16851