Skip to content

The struct type of message(CLUSTERMSG_TYPE_MODULE) in the following code may be used incorrectly #7634

@hujiang001

Description

@hujiang001

The struct type of message(CLUSTERMSG_TYPE_MODULE) in the following code may be used incorrectly.

--------------file: cluster.c, function: clusterProcessPacket--------------------------

} else if (type == CLUSTERMSG_TYPE_MODULE) {
uint32_t explen = sizeof(clusterMsg)-sizeof(union clusterMsgData);
// should be sizeof(clusterMsgModule) ??
explen += sizeof(clusterMsgDataPublish) -
3 + ntohl(hdr->data.module.msg.len);
if (totlen != explen) return 1;
}


It didn't cause an error, because sizeof(clusterMsgDataPublish) is equal to sizeof(clusterMsgModule).
I think this is a risk in later code maintenance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions