#include <mach/host_special_ports.h>
#include <mach/audit_triggers_server.h>
+#include <os/overflow.h>
+
extern void ipc_port_release_send(ipc_port_t port);
#if CONFIG_AUDIT
#endif
{
struct mhdr *hdr;
- size_t memsize = sizeof (*hdr) + size;
+ size_t memsize;
+ if (os_add_overflow(sizeof(*hdr), size, &memsize)) {
+ return (NULL);
+ }
if (size == 0)
return (NULL);
return;
hdr = addr; hdr--;
- KASSERT(hdr->mh_magic == AUDIT_MHMAGIC,
- ("_audit_free(): hdr->mh_magic != AUDIT_MHMAGIC"));
+ if (hdr->mh_magic != AUDIT_MHMAGIC) {
+ panic("_audit_free(): hdr->mh_magic (%lx) != AUDIT_MHMAGIC", hdr->mh_magic);
+ }
#if AUDIT_MALLOC_DEBUG
if (type != NULL) {