diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2009-12-20 15:28:17 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2009-12-20 15:28:17 +0100 |
commit | 8451b436124bd7fdf9c907ebb24687dec10e12bf (patch) | |
tree | c865386f1d6104c45f7bd8ed63c7978703f4be00 | |
parent | 913d709e15209b2c33fdf146b4ad9d59737ab6a3 (diff) |
Fix port leak when directly calling MIG stubs
* auth/auth.c (S_auth_server_authenticate): Check result of
auth_server_authenticate_reply stub.
* init/init.c (S_msg_sig_post_untraced): Check result of
msg_sig_post_untraced_reply
(S_msg_sig_post): Check result of msg_sig_post_reply.
-rw-r--r-- | auth/auth.c | 16 | ||||
-rw-r--r-- | init/init.c | 12 |
2 files changed, 20 insertions, 8 deletions
diff --git a/auth/auth.c b/auth/auth.c index 3c5fa861..fd7c018f 100644 --- a/auth/auth.c +++ b/auth/auth.c @@ -367,6 +367,7 @@ S_auth_server_authenticate (struct authhandle *serverauth, { struct pending *u; struct authhandle *user; + error_t err; if (! serverauth) return EOPNOTSUPP; @@ -399,7 +400,6 @@ S_auth_server_authenticate (struct authhandle *serverauth, /* No pending user RPC for this port. Create a pending server RPC record. */ struct pending s; - error_t err; err = hurd_ihash_add (&pending_servers, rendezvous, &s); if (! err) @@ -428,12 +428,16 @@ S_auth_server_authenticate (struct authhandle *serverauth, /* Extract the ids. We must use a separate reply stub so we can deref the user auth handle after the reply uses its contents. */ - auth_server_authenticate_reply (reply, reply_type, 0, - user->euids.ids, user->euids.num, - user->auids.ids, user->auids.num, - user->egids.ids, user->egids.num, - user->agids.ids, user->agids.num); + err = auth_server_authenticate_reply (reply, reply_type, 0, + user->euids.ids, user->euids.num, + user->auids.ids, user->auids.num, + user->egids.ids, user->egids.num, + user->agids.ids, user->agids.num); + ports_port_deref (user); + if (err) + return err; + mach_port_deallocate (mach_task_self (), rendezvous); return MIG_NO_REPLY; } diff --git a/init/init.c b/init/init.c index d66bee0b..46457293 100644 --- a/init/init.c +++ b/init/init.c @@ -1353,12 +1353,16 @@ S_msg_sig_post_untraced (mach_port_t msgport, mach_port_t reply, mach_msg_type_name_t reply_type, int signo, natural_t sigcode, mach_port_t refport) { + kern_return_t err; + if (refport != mach_task_self ()) return EPERM; mach_port_deallocate (mach_task_self (), refport); /* Reply immediately */ - msg_sig_post_untraced_reply (reply, reply_type, 0); + err = msg_sig_post_untraced_reply (reply, reply_type, 0); + if (err) + return err; process_signal (signo); return MIG_NO_REPLY; @@ -1369,12 +1373,16 @@ S_msg_sig_post (mach_port_t msgport, mach_port_t reply, mach_msg_type_name_t reply_type, int signo, natural_t sigcode, mach_port_t refport) { + kern_return_t err; + if (refport != mach_task_self ()) return EPERM; mach_port_deallocate (mach_task_self (), refport); /* Reply immediately */ - msg_sig_post_reply (reply, reply_type, 0); + err = msg_sig_post_reply (reply, reply_type, 0); + if (err) + return err; process_signal (signo); return MIG_NO_REPLY; |