diff options
author | Charles-François Natali <neologix@free.fr> | 2011-08-28 16:23:43 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-08-28 16:23:43 (GMT) |
commit | 466517df0e272f1b5d46d4e5eed112cefec3d7e3 (patch) | |
tree | 4e59fde04aa39673db1fcfd60d3df4f23f3f184b | |
parent | ac7e9e058d8da18d0002f2b9456900c34a13e463 (diff) | |
download | cpython-466517df0e272f1b5d46d4e5eed112cefec3d7e3.zip cpython-466517df0e272f1b5d46d4e5eed112cefec3d7e3.tar.gz cpython-466517df0e272f1b5d46d4e5eed112cefec3d7e3.tar.bz2 |
Issue #12837: POSIX.1-2008 allows socklen_t to be a signed integer: re-enable
the check against negative values, and add a note on this surprising test.
Patch by David Watson.
-rw-r--r-- | Modules/socketmodule.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index f56e9af..79ccae8 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1745,7 +1745,8 @@ cmsg_min_space(struct msghdr *msg, struct cmsghdr *cmsgh, size_t space) static const size_t cmsg_len_end = (offsetof(struct cmsghdr, cmsg_len) + sizeof(cmsgh->cmsg_len)); - if (cmsgh == NULL || msg->msg_control == NULL) + /* Note that POSIX allows msg_controllen to be of signed type. */ + if (cmsgh == NULL || msg->msg_control == NULL || msg->msg_controllen < 0) return 0; if (space < cmsg_len_end) space = cmsg_len_end; |