From: Sergey Bugaev Date: Sun, 23 Apr 2023 16:05:47 +0000 (+0300) Subject: hurd: Only deallocate addrport when it's valid X-Git-Tag: glibc-2.38~344 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4c39333050815a33ddf4f3067798ac060eed1e2b;p=thirdparty%2Fglibc.git hurd: Only deallocate addrport when it's valid Signed-off-by: Sergey Bugaev Message-Id: <20230423160548.126576-3-bugaevc@gmail.com> --- diff --git a/sysdeps/mach/hurd/recv.c b/sysdeps/mach/hurd/recv.c index 3bd5c16fbdc..1783e38dcb5 100644 --- a/sysdeps/mach/hurd/recv.c +++ b/sysdeps/mach/hurd/recv.c @@ -54,7 +54,8 @@ __recv (int fd, void *buf, size_t n, int flags) if (err) return __hurd_sockfail (fd, flags, err); - __mach_port_deallocate (__mach_task_self (), addrport); + if (MACH_PORT_VALID (addrport)) + __mach_port_deallocate (__mach_task_self (), addrport); __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen); if (bufp != buf) diff --git a/sysdeps/mach/hurd/recvfrom.c b/sysdeps/mach/hurd/recvfrom.c index 1cd5f917466..6f2c927ab6e 100644 --- a/sysdeps/mach/hurd/recvfrom.c +++ b/sysdeps/mach/hurd/recvfrom.c @@ -94,7 +94,8 @@ __recvfrom (int fd, void *buf, size_t n, int flags, __SOCKADDR_ARG addrarg, else if (addr_len != NULL) *addr_len = 0; - __mach_port_deallocate (__mach_task_self (), addrport); + if (MACH_PORT_VALID (addrport)) + __mach_port_deallocate (__mach_task_self (), addrport); /* Toss control data; we don't care. */ __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen); diff --git a/sysdeps/mach/hurd/recvmsg.c b/sysdeps/mach/hurd/recvmsg.c index 39de86f64f2..90fd2698c02 100644 --- a/sysdeps/mach/hurd/recvmsg.c +++ b/sysdeps/mach/hurd/recvmsg.c @@ -135,7 +135,8 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags) else if (message->msg_name != NULL) message->msg_namelen = 0; - __mach_port_deallocate (__mach_task_self (), aport); + if (MACH_PORT_VALID (aport)) + __mach_port_deallocate (__mach_task_self (), aport); if (buf == data) buf += len; diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c index 5871d1d8dd3..7106faf0ded 100644 --- a/sysdeps/mach/hurd/sendmsg.c +++ b/sysdeps/mach/hurd/sendmsg.c @@ -195,8 +195,9 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) message->msg_controllen, &amount); LIBC_CANCEL_RESET (cancel_oldtype); - __mach_port_deallocate (__mach_task_self (), - aport); + if (MACH_PORT_VALID (aport)) + __mach_port_deallocate (__mach_task_self (), + aport); } err; })); diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c index 5a960de8ce8..777af1c4d64 100644 --- a/sysdeps/mach/hurd/sendto.c +++ b/sysdeps/mach/hurd/sendto.c @@ -94,7 +94,7 @@ __sendto (int fd, err; })); - if (aport != MACH_PORT_NULL) + if (MACH_PORT_VALID (aport)) __mach_port_deallocate (__mach_task_self (), aport); return err ? __hurd_sockfail (fd, flags, err) : wrote;