aboutsummaryrefslogtreecommitdiff
path: root/proc
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2021-05-29 17:07:24 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-10 22:14:53 +0200
commit008a7e92c54c2f71f282527241d18875be61ecf3 (patch)
tree80aae723a5490c0c4eb7928e5dfce1a11877c57c /proc
parent3c9f1482b6890cfed89880e728ec6114e37c33d4 (diff)
downloadhurd-008a7e92c54c2f71f282527241d18875be61ecf3.tar.gz
hurd-008a7e92c54c2f71f282527241d18875be61ecf3.tar.bz2
hurd-008a7e92c54c2f71f282527241d18875be61ecf3.zip
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.
Diffstat (limited to 'proc')
-rw-r--r--proc/mgt.c13
1 files changed, 9 insertions, 4 deletions
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)