#include <security/mac_framework.h>
#endif
+
lck_grp_t * sysctl_lock_group = NULL;
lck_rw_t * sysctl_geometry_lock = NULL;
lck_mtx_t * sysctl_unlocked_node_lock = NULL;
new_oidp->oid_number = oidp->oid_number;
}
+
/*
* Insert the oid into the parent's list in order.
*/
}
}
+
/*
* We've removed it from the list at this point, but we don't want
* to return to the caller until all handler references have drained
int error = 0;
struct sysctl_oid *oid;
struct sysctl_oid_list *lsp = &sysctl__children, *lsp2;
- char tempbuf[10];
+ char tempbuf[10] = {};
lck_rw_lock_shared(sysctl_geometry_lock);
while (namelen) {
int i, j, error;
struct sysctl_oid *oid;
struct sysctl_oid_list *lsp = &sysctl__children;
- int newoid[CTL_MAXNAME];
+ int newoid[CTL_MAXNAME] = {};
lck_rw_lock_shared(sysctl_geometry_lock);
i = sysctl_sysctl_next_ls (lsp, name, namelen, newoid, &j, 1, &oid);
__unused int arg2, struct sysctl_req *req)
{
char *p;
- int error, oid[CTL_MAXNAME];
+ int error, oid[CTL_MAXNAME] = {};
u_int len = 0; /* set by name2oid() */
if (req->newlen < 1)
int i;
struct sysctl_oid *oid;
struct sysctl_oid_list *lsp = &sysctl__children;
+ sysctl_handler_t oid_handler = NULL;
int error;
boolean_t unlocked_node_found = FALSE;
boolean_t namestring_started = FALSE;
(error = proc_suser(req->p)))
goto err;
- if (!oid->oid_handler) {
+ /*
+ * sysctl_unregister_oid() may change the handler value, so grab it
+ * under the lock.
+ */
+ oid_handler = oid->oid_handler;
+ if (!oid_handler) {
error = EINVAL;
goto err;
}
lck_mtx_lock(sysctl_unlocked_node_lock);
}
+
if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
- i = (oid->oid_handler) (oid,
- name + indx, namelen - indx,
- req);
+ i = oid_handler(oid, name + indx, namelen - indx, req);
} else {
- i = (oid->oid_handler) (oid,
- oid->oid_arg1, oid->oid_arg2,
- req);
+ i = oid_handler(oid, oid->oid_arg1, oid->oid_arg2, req);
}
error = i;