summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp')
-rw-r--r--Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp b/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
index 18d02cdd9..3902003f9 100644
--- a/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
+++ b/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
@@ -199,6 +199,11 @@ bool Connection::processMessage()
memcpy(&messageInfo, messageData, sizeof(messageInfo));
messageData += sizeof(messageInfo);
+ if (messageInfo.attachmentCount() > attachmentMaxAmount || (!messageInfo.isMessageBodyIsOutOfLine() && messageInfo.bodySize() > messageMaxSize)) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
size_t messageLength = sizeof(MessageInfo) + messageInfo.attachmentCount() * sizeof(AttachmentInfo) + (messageInfo.isMessageBodyIsOutOfLine() ? 0 : messageInfo.bodySize());
if (m_readBuffer.size() < messageLength)
return false;
@@ -256,7 +261,7 @@ bool Connection::processMessage()
if (messageInfo.isMessageBodyIsOutOfLine()) {
ASSERT(messageInfo.bodySize());
- if (attachmentInfo[attachmentCount].isNull()) {
+ if (attachmentInfo[attachmentCount].isNull() || attachmentInfo[attachmentCount].getSize() != messageInfo.bodySize()) {
ASSERT_NOT_REACHED();
return false;
}
@@ -334,6 +339,10 @@ static ssize_t readBytesFromSocket(int socketDescriptor, Vector<uint8_t>& buffer
struct cmsghdr* controlMessage;
for (controlMessage = CMSG_FIRSTHDR(&message); controlMessage; controlMessage = CMSG_NXTHDR(&message, controlMessage)) {
if (controlMessage->cmsg_level == SOL_SOCKET && controlMessage->cmsg_type == SCM_RIGHTS) {
+ if (controlMessage->cmsg_len < CMSG_LEN(0) || controlMessage->cmsg_len > attachmentMaxAmount) {
+ ASSERT_NOT_REACHED();
+ break;
+ }
size_t previousFileDescriptorsSize = fileDescriptors.size();
size_t fileDescriptorsCount = (controlMessage->cmsg_len - CMSG_LEN(0)) / sizeof(int);
fileDescriptors.grow(fileDescriptors.size() + fileDescriptorsCount);