summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/uthread
diff options
context:
space:
mode:
authormarc <marc@openbsd.org>2002-10-21 23:10:29 +0000
committermarc <marc@openbsd.org>2002-10-21 23:10:29 +0000
commit41e2357fa9b421e1298b000e242d3f96247113a7 (patch)
tree084419687c42d7117d48726831c059bc30bd7d30 /lib/libpthread/uthread
parentANSI (diff)
downloadwireguard-openbsd-41e2357fa9b421e1298b000e242d3f96247113a7.tar.xz
wireguard-openbsd-41e2357fa9b421e1298b000e242d3f96247113a7.zip
Check for null pointer before deref in info output. Based upon
a freebsd patch forwarded to me by millert@ (thanks!). Change also applied to uthread_info.c even though we do not use it
Diffstat (limited to 'lib/libpthread/uthread')
-rw-r--r--lib/libpthread/uthread/uthread_info.c12
-rw-r--r--lib/libpthread/uthread/uthread_info_openbsd.c13
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/libpthread/uthread/uthread_info.c b/lib/libpthread/uthread/uthread_info.c
index fc2f739962c..b528f9bd64e 100644
--- a/lib/libpthread/uthread/uthread_info.c
+++ b/lib/libpthread/uthread/uthread_info.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_info.c,v 1.10 2001/08/21 19:24:53 fgsch Exp $ */
+/* $OpenBSD: uthread_info.c,v 1.11 2002/10/21 23:10:29 marc Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -152,9 +152,13 @@ _thread_dump_info(void)
pthread->data.fd.fname,
pthread->data.fd.branch);
_thread_sys_write(fd, s, strlen(s));
- snprintf(s, sizeof(s), "owner %pr/%pw\n",
- _thread_fd_table[pthread->data.fd.fd]->r_owner,
- _thread_fd_table[pthread->data.fd.fd]->w_owner);
+ if (_thread_fd_table[pthread->data.fd.fd])
+ snprintf(s, sizeof(s), "owner %pr/%pw\n",
+ _thread_fd_table[pthread->data.fd.fd]->r_owner,
+ _thread_fd_table[pthread->data.fd.fd]->w_owner);
+ else
+ snprintf(s, sizeof(s), "owner [unknown]\n");
+
_thread_sys_write(fd, s, strlen(s));
break;
case PS_SIGWAIT:
diff --git a/lib/libpthread/uthread/uthread_info_openbsd.c b/lib/libpthread/uthread/uthread_info_openbsd.c
index a9f133550e9..be3423b9ba7 100644
--- a/lib/libpthread/uthread/uthread_info_openbsd.c
+++ b/lib/libpthread/uthread/uthread_info_openbsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_info_openbsd.c,v 1.5 2001/12/11 00:19:47 fgsch Exp $ */
+/* $OpenBSD: uthread_info_openbsd.c,v 1.6 2002/10/21 23:10:30 marc Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
@@ -188,10 +188,13 @@ _thread_dump_entry(pthread, fd, verbose)
pthread->data.fd.branch);
_thread_sys_write(fd, s, strlen(s));
s[0] = 0;
- snprintf(s, sizeof(s), "%s owner %pr/%pw\n",
- info_lead,
- _thread_fd_table[pthread->data.fd.fd]->r_owner,
- _thread_fd_table[pthread->data.fd.fd]->w_owner);
+ if (_thread_fd_table[pthread->data.fd.fd])
+ snprintf(s, sizeof(s), "%s owner %pr/%pw\n",
+ info_lead,
+ _thread_fd_table[pthread->data.fd.fd]->r_owner,
+ _thread_fd_table[pthread->data.fd.fd]->w_owner);
+ else
+ snprintf(s, sizeof(s), "%s owner [unknown]\n", info_lead);
_thread_sys_write(fd, s, strlen(s));
break;
case PS_SIGWAIT: