X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/866f8763175ff60e4fa455b92b5eb660a12fe6c7..7e6b461318c8a779d91381531435a68ee4e8b6ed:/securityd/src/SharedMemoryServer.cpp?ds=sidebyside diff --git a/securityd/src/SharedMemoryServer.cpp b/securityd/src/SharedMemoryServer.cpp index 3b95482b..60176b1b 100644 --- a/securityd/src/SharedMemoryServer.cpp +++ b/securityd/src/SharedMemoryServer.cpp @@ -32,25 +32,13 @@ #include #include #include +#include /* Logically, these should go in /var/run/mds, but we know that /var/db/mds already exists at install time. */ -std::string SharedMemoryCommon::SharedMemoryFilePath(const char *segmentName, uid_t uid) { - std::string path; - uid = SharedMemoryCommon::fixUID(uid); - path = SharedMemoryCommon::kMDSMessagesDirectory; // i.e. /private/var/db/mds/messages/ - if (uid != 0) { - path += std::to_string(uid) + "/"; // e.g. /private/var/db/mds/messages/501/ - } - - path += SharedMemoryCommon::kUserPrefix; // e.g. /var/db/mds/messages/se_ - path += segmentName; // e.g. /var/db/mds/messages/501/se_SecurityMessages - return path; -} - static bool makedir(const char *path, mode_t mode) { // Returns true on success. Primarily to centralize logging if (::mkdir(path, mode)==0 || errno==EEXIST) { @@ -166,13 +154,13 @@ void SharedMemoryServer::WriteMessage (SegmentOffsetType domain, SegmentOffsetTy // assemble the final message ssize_t messageSize = kHeaderLength + messageLength; - u_int8_t finalMessage[messageSize]; - SegmentOffsetType *fm = (SegmentOffsetType*) finalMessage; + std::vector finalMessage(messageSize); + SegmentOffsetType *fm = (SegmentOffsetType*) finalMessage.data(); fm[0] = OSSwapHostToBigInt32(domain); fm[1] = OSSwapHostToBigInt32(event); memcpy(&fm[2], message, messageLength); - SegmentOffsetType crc = CalculateCRC(finalMessage, messageSize); + SegmentOffsetType crc = CalculateCRC(finalMessage.data(), messageSize); // write the length WriteOffset(int_cast(messageSize)); @@ -181,7 +169,7 @@ void SharedMemoryServer::WriteMessage (SegmentOffsetType domain, SegmentOffsetTy WriteOffset(crc); // write the data - WriteData (finalMessage, int_cast(messageSize)); + WriteData (finalMessage.data(), int_cast(messageSize)); // write the data count SetProducerOffset(int_cast(mDataPtr - mDataArea));