diff options
author | marcel <marcel@FreeBSD.org> | 2004-07-11 15:22:43 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2004-07-11 15:22:43 +0000 |
commit | 9365674e5cd0355c4f6feae454762d8a0bada2d0 (patch) | |
tree | cafeff92173564e603410ba2452862d849dc6b43 /sys/kern | |
parent | 3683e698d2b43b057fd00f831207c4322511e44d (diff) | |
download | FreeBSD-src-9365674e5cd0355c4f6feae454762d8a0bada2d0.zip FreeBSD-src-9365674e5cd0355c4f6feae454762d8a0bada2d0.tar.gz |
Fix braino: Make sure there is a current backend before we return its
name in the debug.kdb.current sysctl. All other dereferences are
properly guarded, but this one was overlooked.
Reported by: Morten Rodal (morten at rodal dot no)
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_kdb.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 467d217..1c91deb 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -104,8 +104,11 @@ kdb_sysctl_current(SYSCTL_HANDLER_ARGS) struct kdb_dbbe *be, **iter; int error; - strncpy(buf, kdb_dbbe->dbbe_name, sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; + if (kdb_dbbe != NULL) { + strncpy(buf, kdb_dbbe->dbbe_name, sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; + } else + *buf = '\0'; error = sysctl_handle_string(oidp, buf, sizeof(buf), req); if (error != 0 || req->newptr == NULL) return (error); |