From 3b882621b5de27c1c3ee619ea303eb6448459e8f Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 13 Jul 2001 21:27:43 +0000 Subject: 2001-07-13 Marcus Brinkmann * host.c (S_proc_getexecdata): New variable PORTS_ALLOCATED. Set it if we allocated a new buffer for PORTS. If it is set, and allocation of a new buffer for INTS fails, unmap the buffer for PORTS. * host.c (S_proc_getexecdata): New variable I. Go over all standard ports and increase the send right user reference by one. Set *PORTSPOLY to MACH_MSG_TYPE_MOVE_SEND. --- proc/ChangeLog | 11 +++++++++++ proc/host.c | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'proc') diff --git a/proc/ChangeLog b/proc/ChangeLog index 79d1861e..08f100a2 100644 --- a/proc/ChangeLog +++ b/proc/ChangeLog @@ -1,3 +1,14 @@ +2001-07-13 Marcus Brinkmann + + * host.c (S_proc_getexecdata): New variable PORTS_ALLOCATED. + Set it if we allocated a new buffer for PORTS. If it is set, + and allocation of a new buffer for INTS fails, unmap the buffer + for PORTS. + + * host.c (S_proc_getexecdata): New variable I. Go over all + standard ports and increase the send right user reference by one. + Set *PORTSPOLY to MACH_MSG_TYPE_MOVE_SEND. + 2001-06-27 Marcus Brinkmann * info.c (S_proc_getprocinfo): If we return because mmap failed diff --git a/proc/host.c b/proc/host.c index 30353a05..b0f7d6e1 100644 --- a/proc/host.c +++ b/proc/host.c @@ -138,6 +138,8 @@ S_proc_getexecdata (struct proc *p, int **ints, u_int *nints) { + int i; + int ports_allocated = 0; /* No need to check P here; we don't use it. */ if (!std_port_array) @@ -149,6 +151,7 @@ S_proc_getexecdata (struct proc *p, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); if (*ports == MAP_FAILED) return ENOMEM; + ports_allocated = 1; } memcpy (*ports, std_port_array, n_std_ports * sizeof (mach_port_t)); *nports = n_std_ports; @@ -158,11 +161,19 @@ S_proc_getexecdata (struct proc *p, *ints = mmap (0, round_page (n_std_ints * sizeof (int)), PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); if (*ints == MAP_FAILED) - return ENOMEM; + { + if (ports_allocated) + munmap (*ports, round_page (n_std_ports * sizeof (mach_port_t))); + return ENOMEM; + } } memcpy (*ints, std_int_array, n_std_ints * sizeof (int)); *nints = n_std_ints; + for (i = 0; i < n_std_ports; i++) + mach_port_mod_refs (mach_task_self (), std_port_array[i], MACH_PORT_RIGHT_SEND, 1); + *portspoly = MACH_MSG_TYPE_MOVE_SEND; + return 0; } -- cgit v1.2.3