* auth/auth.c (S_auth_user_authenticate, S_auth_server_authenticate): Fail with EINVAL if RENDEZVOUS is MACH_PORT_NULL.
--- Hi, This patch makes the auth server fail with EINVAL if the rendezvous port is null. I don't really think this needs much motivation but then again I also didn't think there would be much resistance against checking for MACH_PORT_DEAD in the interruption handling. ;-) So here goes: not only does the current situation make auth do a bunch of unnecessary work and locking which can interfere with other transactions, it also fails with EINTR, which a typical client would respond by trying the RPC again, which makes it loop indefinitely, causing even more work for auth itself. I also removed a comment, mostly because I didn't know where to put it, but also because it's a slightly misleading as it is not impossible for the client to simply send an already dead port. I felt the best alternative was to change it to "Invalid port." or something, which could apply to both conditions, but this is already obvious from the code. Shall I commit? Regards, Fredrik --- auth/auth.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/auth/auth.c b/auth/auth.c index 2afeaf7..8422cea 100644 --- a/auth/auth.c +++ b/auth/auth.c @@ -285,7 +285,7 @@ S_auth_user_authenticate (struct authhandle *userauth, if (! userauth) return EOPNOTSUPP; - if (rendezvous == MACH_PORT_DEAD) /* Port died in transit. */ + if (rendezvous == MACH_PORT_NULL || rendezvous == MACH_PORT_DEAD) return EINVAL; mutex_lock (&pending_lock); @@ -373,7 +373,7 @@ S_auth_server_authenticate (struct authhandle *serverauth, if (! serverauth) return EOPNOTSUPP; - if (rendezvous == MACH_PORT_DEAD) /* Port died in transit. */ + if (rendezvous == MACH_PORT_NULL || rendezvous == MACH_PORT_DEAD) return EINVAL; mutex_lock (&pending_lock); -- tg: (5923172..) t/auth-null-port (depends on: master)