Bertrand Janin added the comment:

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;

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23127>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to