]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #12837: POSIX.1-2008 allows socklen_t to be a signed integer: re-enable
authorCharles-François Natali <neologix@free.fr>
Sun, 28 Aug 2011 16:23:43 +0000 (18:23 +0200)
committerCharles-François Natali <neologix@free.fr>
Sun, 28 Aug 2011 16:23:43 +0000 (18:23 +0200)
the check against negative values, and add a note on this surprising test.
Patch by David Watson.

Modules/socketmodule.c

index f56e9afd52d0f55fb51748e1b2429338997e1ed1..79ccae8cdbc4b0ffc8d6b2c8d2a6343a8dd7312f 100644 (file)
@@ -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;