MCPcopy Create free account
hub / github.com/F-Stack/f-stack / au_evclassmap_insert

Function au_evclassmap_insert

freebsd/security/audit/audit_bsm_db.c:142–169  ·  view source on GitHub ↗

* Insert a event to class mapping. If the event already exists in the * mapping, then replace the mapping with the new one. * * XXX There is currently no constraints placed on the number of mappings. * May want to either limit to a number, or in terms of memory usage. */

Source from the content-addressed store, hash-verified

140 * May want to either limit to a number, or in terms of memory usage.
141 */
142void
143au_evclassmap_insert(au_event_t event, au_class_t class)
144{
145 struct evclass_list *evcl;
146 struct evclass_elem *evc, *evc_new;
147
148 /*
149 * Pessimistically, always allocate storage before acquiring mutex.
150 * Free if there is already a mapping for this event.
151 */
152 evc_new = malloc(sizeof(*evc), M_AUDITEVCLASS, M_WAITOK);
153
154 EVCLASS_WLOCK();
155 evcl = &evclass_hash[event % EVCLASSMAP_HASH_TABLE_SIZE];
156 LIST_FOREACH(evc, &evcl->head, entry) {
157 if (evc->event == event) {
158 evc->class = class;
159 EVCLASS_WUNLOCK();
160 free(evc_new, M_AUDITEVCLASS);
161 return;
162 }
163 }
164 evc = evc_new;
165 evc->event = event;
166 evc->class = class;
167 LIST_INSERT_HEAD(&evcl->head, evc, entry);
168 EVCLASS_WUNLOCK();
169}
170
171void
172au_evclassmap_init(void)

Callers 2

sys_auditonFunction · 0.85
au_evclassmap_initFunction · 0.85

Calls 2

mallocFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected