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)
This commit is contained in:
Marcel Moolenaar 2004-07-11 15:22:43 +00:00
parent 911dbd84c7
commit a8bfba1a27

View File

@ -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);