diff Modules/socketmodule.c @ 72117:3ed2d087e70d

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.
author Charles-François Natali <neologix@free.fr>
date Sun, 28 Aug 2011 18:23:43 +0200
parents ad1c09b6a5b9
children b534b56379cb
line wrap: on
line diff
--- a/Modules/socketmodule.c	Sun Aug 28 18:10:27 2011 +0200
+++ b/Modules/socketmodule.c	Sun Aug 28 18:23:43 2011 +0200
@@ -1745,7 +1745,8 @@
     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;