diff options
author | Marco S Hyman <marc@cvs.openbsd.org> | 2002-10-21 23:10:31 +0000 |
---|---|---|
committer | Marco S Hyman <marc@cvs.openbsd.org> | 2002-10-21 23:10:31 +0000 |
commit | d90665a3da85f897f6c6e18fada0d2962934bf35 (patch) | |
tree | a7d5bbf797fbe746e2e2d829c0f10a69fb01df98 | |
parent | af9eceb870c789db8973971f778d5e3d994cf8a5 (diff) |
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
-rw-r--r-- | lib/libc_r/uthread/uthread_info.c | 12 | ||||
-rw-r--r-- | lib/libc_r/uthread/uthread_info_openbsd.c | 13 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_info.c | 12 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_info_openbsd.c | 13 |
4 files changed, 32 insertions, 18 deletions
diff --git a/lib/libc_r/uthread/uthread_info.c b/lib/libc_r/uthread/uthread_info.c index fc2f739962c..b528f9bd64e 100644 --- a/lib/libc_r/uthread/uthread_info.c +++ b/lib/libc_r/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/libc_r/uthread/uthread_info_openbsd.c b/lib/libc_r/uthread/uthread_info_openbsd.c index a9f133550e9..be3423b9ba7 100644 --- a/lib/libc_r/uthread/uthread_info_openbsd.c +++ b/lib/libc_r/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: 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: |