[issue3372] socket.setsockopt() is broken for multicast TTL and Loop options
Bertrand Janin
report at bugs.python.org
Mon Dec 29 03:29:19 CET 2014
Bertrand Janin added the comment:
This is still an issue as of OpenBSD 5.6. Here is an updated patch for the latest 2.7 branch:
diff -r 88de50c1696b Modules/socketmodule.c
--- a/Modules/socketmodule.c Sun Dec 28 18:51:25 2014 +0200
+++ b/Modules/socketmodule.c Sun Dec 28 21:24:41 2014 -0500
@@ -1881,24 +1881,29 @@
{
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;
+ /* Multi cast options take shorter arguments */
+ if (optname == IP_MULTICAST_TTL
+ || optname == IP_MULTICAST_LOOP)
+ buflen = sizeof(u_char);
+ buf = (char *) &flag;
}
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;
----------
nosy: +tamentis
versions: +Python 2.7, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3372>
_______________________________________
More information about the Python-bugs-list
mailing list