From ad63bae03cf0eb9edced3803cbcd0cee02377050 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Jan 2022 16:27:03 +0100 Subject: portinfo: Do not compare port to anything when it is MACH_PORT_DEAD Otherwise it would successfully compare to any port that happens to be MACH_PORT_DEAD, e.g. the bootstrap port. --- libshouldbeinlibc/portinfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libshouldbeinlibc/portinfo.c b/libshouldbeinlibc/portinfo.c index de087de9..a023446a 100644 --- a/libshouldbeinlibc/portinfo.c +++ b/libshouldbeinlibc/portinfo.c @@ -119,7 +119,10 @@ print_port_info (mach_port_t name, mach_port_type_t type, task_t task, mach_port_t msgport; pid_t pid; - err = proc_task2pid (proc, task, &pid); + if (port == MACH_PORT_DEAD) + err = EIEIO; + else + err = proc_task2pid (proc, task, &pid); if (!err) err = proc_getmsgport (proc, pid, &msgport); if (!err) -- cgit v1.2.3