From d1eca298a62e3eb7ebedaa0d176a1d310c1a53ce Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 30 May 1999 03:10:19 +0000 Subject: 1999-05-29 Roland McGrath * mgt.c (add_tasks): Skip invalid (null) rights in tasks array. * info.c (S_proc_pid2task): Add assert for p_task right validity. --- proc/info.c | 5 +++-- proc/mgt.c | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'proc') diff --git a/proc/info.c b/proc/info.c index 1a398461..a53df08a 100644 --- a/proc/info.c +++ b/proc/info.c @@ -1,5 +1,5 @@ /* Process information queries - Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1992,93,94,95,96,99 Free Software Foundation, Inc. This file is part of the GNU Hurd. @@ -55,6 +55,7 @@ S_proc_pid2task (struct proc *callerp, if (! check_owner (callerp, p)) return EPERM; + assert (MACH_PORT_VALID (p->p_task)); *t = p->p_task; return 0; @@ -426,7 +427,7 @@ S_proc_getprocinfo (struct proc *callerp, assert (tp); pi->logincollection = tp->p_pid; if (p->p_dead || p->p_stopped) - { + { pi->exitstatus = p->p_status; pi->sigcode = p->p_sigcode; } diff --git a/proc/mgt.c b/proc/mgt.c index 3f4f5f3b..cde05cd0 100644 --- a/proc/mgt.c +++ b/proc/mgt.c @@ -238,7 +238,7 @@ S_proc_reassign (struct proc *p, p->p_envp = stubp->p_envp; /* Destroy stubp */ - stubp->p_task = 0; /* block deallocation */ + stubp->p_task = MACH_PORT_NULL;/* block deallocation */ process_has_exited (stubp); stubp->p_waited = 1; /* fake out complete_exit */ complete_exit (stubp); @@ -750,6 +750,12 @@ add_tasks (task_t task) for (j = 0; j < ntasks; j++) { int set = 0; + + /* The kernel can deliver us an array with null slots in the + middle, e.g. if a task died during the call. */ + if (! MACH_PORT_VALID (tasks[j])) + continue; + if (!foundp) { struct proc *p = task_find_nocreate (tasks[j]); -- cgit v1.2.3