X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/2965425374ca4413339436c2f706f7b5508402e2..ce0ac947b4708d0bc1c7e6789b3e1f3bfc80d6e9:/cdsa/cdsa_utilities/machrunloopserver.cpp diff --git a/cdsa/cdsa_utilities/machrunloopserver.cpp b/cdsa/cdsa_utilities/machrunloopserver.cpp index 3a621a21..cf860dbf 100644 --- a/cdsa/cdsa_utilities/machrunloopserver.cpp +++ b/cdsa/cdsa_utilities/machrunloopserver.cpp @@ -83,10 +83,10 @@ void MachRunLoopServer::blockNewRequests(bool block) { if (block) { CFRunLoopRemoveSource(runLoop, runLoopSource, kCFRunLoopDefaultMode); - debug("machsrv", "disabled request reception"); + secdebug("machsrv", "disabled request reception"); } else { CFRunLoopAddSource(runLoop, runLoopSource, kCFRunLoopDefaultMode); - debug("machsrv", "enabled request reception"); + secdebug("machsrv", "enabled request reception"); } } @@ -101,7 +101,7 @@ void MachRunLoopServer::alsoListenOn(Port port) CFRef source = CFMachPortCreateRunLoopSource(NULL, cfPort, 10); //@@@ no idea what order is good CFRunLoopAddSource(runLoop, source, kCFRunLoopDefaultMode); - debug("machsrv", "also receiving from port %d", port.port()); + secdebug("machsrv", "also receiving from port %d", port.port()); } void MachRunLoopServer::stopListenOn(Port port) @@ -111,7 +111,7 @@ void MachRunLoopServer::stopListenOn(Port port) CFRef source = CFMachPortCreateRunLoopSource(NULL, cfPort, 10); //@@@ no idea what order is good CFRunLoopRemoveSource(runLoop, source, kCFRunLoopDefaultMode); - debug("machsrv", "no longer receiving from port %d", port.port()); + secdebug("machsrv", "no longer receiving from port %d", port.port()); } @@ -125,7 +125,10 @@ void MachRunLoopServer::notifyIfDead(Port port) const //@@@ not clear how to deal with CFRetainCount of cfPort here // will CF clean up the cfPort when it dies? Or do we have to keep a set? CFMachPortRef cfPort = CFMachPortCreateWithPort(NULL, port, NULL, NULL, NULL); - CFMachPortSetInvalidationCallBack(cfPort, cfInvalidateCallback); + if (cfPort != NULL) // check to make sure that we got a valid port reference back + { + CFMachPortSetInvalidationCallBack(cfPort, cfInvalidateCallback); + } } void MachRunLoopServer::cfInvalidateCallback(CFMachPortRef cfPort, void *) @@ -147,20 +150,20 @@ void MachRunLoopServer::oneRequest(mach_msg_header_t *request) if (!handle(request, replyBuffer)) { // MIG dispatch did not recognize the request. Ignore/Retry/Fail? :-) //@@@ Should send an error reply back here, I suppose. Later... - debug("machrls", "MachRunLoopServer dispatch failed"); + secdebug("machrls", "MachRunLoopServer dispatch failed"); return; } // MIG dispatch handled the call. Send reply back to caller. // This boilerplate stolen from mach_msg_server, since MIG can't seem to // generate send-only code for replies (without explicit simpleroutines). - if (kern_return_t err = mach_msg_overwrite(replyBuffer, + if (IFDEBUG(kern_return_t err =) mach_msg_overwrite(replyBuffer, (MACH_MSGH_BITS_REMOTE(replyBuffer->msgh_bits) == MACH_MSG_TYPE_MOVE_SEND_ONCE) ? MACH_SEND_MSG : MACH_SEND_MSG|MACH_SEND_TIMEOUT, replyBuffer->msgh_size, 0, MACH_PORT_NULL, 0, MACH_PORT_NULL, (mach_msg_header_t *) 0, 0)) { //@@@ should at least clean up resources here, I suppose. - debug("machsrv", "RunloopServer cannot post reply: %s", mach_error_string(err)); + secdebug("machsrv", "RunloopServer cannot post reply: %s", mach_error_string(err)); active().releaseDeferredAllocations(); return; }