From 008a7e92c54c2f71f282527241d18875be61ecf3 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Sat, 29 May 2021 17:07:24 +0300 Subject: proc: Fix an error path If the allocation failed, we want to leave the p_ids pointer as it was, and properly propagate the error code. --- proc/mgt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'proc') diff --git a/proc/mgt.c b/proc/mgt.c index 559fedd3..bf82cd7f 100644 --- a/proc/mgt.c +++ b/proc/mgt.c @@ -94,6 +94,7 @@ kern_return_t S_proc_reauthenticate (struct proc *p, mach_port_t rendport) { error_t err; + struct ids *new_ids; uid_t gubuf[50], aubuf[50], ggbuf[50], agbuf[50]; uid_t *gen_uids, *aux_uids, *gen_gids, *aux_gids; size_t ngen_uids, naux_uids, ngen_gids, naux_gids; @@ -133,10 +134,14 @@ S_proc_reauthenticate (struct proc *p, mach_port_t rendport) err = EAGAIN; else { - ids_rele (p->p_id); - p->p_id = make_ids (gen_uids, ngen_uids, aux_uids, naux_uids); - if (! p->p_id) - err = ENOMEM; + new_ids = make_ids (gen_uids, ngen_uids, aux_uids, naux_uids); + if (!new_ids) + err = errno; + else + { + ids_rele (p->p_id); + p->p_id = new_ids; + } } if (gen_uids != gubuf) -- cgit v1.2.3