# HG changeset patch # Parent 5c306845e67c7e136b9c03e537838d99ad4ab175 diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1917,8 +1917,10 @@ cmsg_min_space(struct msghdr *msg, struc static const size_t cmsg_len_end = (offsetof(struct cmsghdr, cmsg_len) + sizeof(cmsgh->cmsg_len)); - /* Note that POSIX allows msg_controllen to be of signed type. */ - if (cmsgh == NULL || msg->msg_control == NULL || msg->msg_controllen < 0) + /* Note that POSIX allows msg_controllen to be of signed type, in + which case we need the comparison to be signed. */ + if (cmsgh == NULL || msg->msg_control == NULL || + msg->msg_controllen < (Py_ssize_t)cmsg_len_end) return 0; if (space < cmsg_len_end) space = cmsg_len_end;