This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tamentis
Recipients benjamin.peterson, tamentis
Date 2014-12-31.19:36:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420054584.9.0.299527200418.issue23127@psf.upfronthosting.co.za>
In-reply-to
Content
Good point, I updated the diff with a better cast to avoid endianness issues (tested on MIPS64) and added an OpenBSD #ifdef, is that more acceptable?

diff -r 88de50c1696b Modules/socketmodule.c
--- a/Modules/socketmodule.c	Sun Dec 28 18:51:25 2014 +0200
+++ b/Modules/socketmodule.c	Wed Dec 31 14:25:55 2014 -0500
@@ -1881,24 +1881,31 @@
 {
     int level;
     int optname;
     int res;
     char *buf;
     int buflen;
     int flag;
 
     if (PyArg_ParseTuple(args, "iii:setsockopt",
                          &level, &optname, &flag)) {
         buf = (char *) &flag;
         buflen = sizeof flag;
+#if defined(__OpenBSD__)
+        /* Multicast options take shorter arguments */
+        if (optname == IP_MULTICAST_TTL || optname == IP_MULTICAST_LOOP) {
+            buflen = sizeof(u_char);
+            *buf = (u_char)flag;
+        }
+#endif
     }
     else {
         PyErr_Clear();
         if (!PyArg_ParseTuple(args, "iis#:setsockopt",
                               &level, &optname, &buf, &buflen))
             return NULL;
     }
     res = setsockopt(s->sock_fd, level, optname, (void *)buf, buflen);
     if (res < 0)
         return s->errorhandler();
     Py_INCREF(Py_None);
     return Py_None;
History
Date User Action Args
2014-12-31 19:36:24tamentissetrecipients: + tamentis, benjamin.peterson
2014-12-31 19:36:24tamentissetmessageid: <1420054584.9.0.299527200418.issue23127@psf.upfronthosting.co.za>
2014-12-31 19:36:24tamentislinkissue23127 messages
2014-12-31 19:36:24tamentiscreate