Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions src/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1835,12 +1835,21 @@ int clusterProcessPacket(clusterLink *link) {
explen += sizeof(clusterMsgDataFail);
if (totlen != explen) return 1;
} else if (type == CLUSTERMSG_TYPE_PUBLISH) {
uint32_t explen = sizeof(clusterMsg)-sizeof(union clusterMsgData);
uint64_t explen = sizeof(clusterMsg)-sizeof(union clusterMsgData);

uint32_t ch_len = ntohl(hdr->data.publish.msg.channel_len);
uint32_t msg_len = ntohl(hdr->data.publish.msg.message_len);

explen += sizeof(clusterMsgDataPublish) - 8;
explen += ch_len;
explen += msg_len;

if (explen > UINT32_MAX) {
serverLog(LL_WARNING,
"Rejecting PUBLISH cluster message: length overflow");
return 1;
}

explen += sizeof(clusterMsgDataPublish) -
8 +
ntohl(hdr->data.publish.msg.channel_len) +
ntohl(hdr->data.publish.msg.message_len);
if (totlen != explen) return 1;
} else if (type == CLUSTERMSG_TYPE_FAILOVER_AUTH_REQUEST ||
type == CLUSTERMSG_TYPE_FAILOVER_AUTH_ACK ||
Expand All @@ -1855,10 +1864,19 @@ int clusterProcessPacket(clusterLink *link) {
explen += sizeof(clusterMsgDataUpdate);
if (totlen != explen) return 1;
} else if (type == CLUSTERMSG_TYPE_MODULE) {
uint32_t explen = sizeof(clusterMsg)-sizeof(union clusterMsgData);
uint64_t explen = sizeof(clusterMsg)-sizeof(union clusterMsgData);

uint32_t module_len = ntohl(hdr->data.module.msg.len);

explen += sizeof(clusterMsgModule) - 3;
explen += module_len;

if (explen > UINT32_MAX) {
serverLog(LL_WARNING,
"Rejecting MODULE cluster message: length overflow");
return 1;
}

explen += sizeof(clusterMsgModule) -
3 + ntohl(hdr->data.module.msg.len);
if (totlen != explen) return 1;
}

Expand Down