jenkins-core-weekly: update to 2.491
[oi-userland.git] / components / python / python37 / patches / 17-setsockopt.patch
bloba0e445a91d99c85d603c697e04f225725fd5d403
1 Fixes bug 30503749.
3 socket.setsockopt sometimes raise Invalid argument error, because of differences
4 between Linux and Solaris in socket layer. The reason is that the third argument
5 length is different for the following socket options:
7 IP_MULTICAST_TTL
8 IP_MULTICAST_LOOP
10 An integer is expected on Linux, single byte on Solaris. While this should be
11 handled in the application code (with pack), we decided to patch this in runtime
12 rather than in our application code (because upstream is generally aware of this).
14 See the bug for more information.
16 --- Python-3.7.5/Modules/socketmodule.c
17 +++ Python-3.7.5/Modules/socketmodule.c
18 @@ -2776,6 +2776,7 @@ sock_setsockopt(PySocketSockObject *s, P
19 int optname;
20 int res;
21 Py_buffer optval;
22 + int buflen;
23 int flag;
24 unsigned int optlen;
25 PyObject *none;
26 @@ -2798,8 +2799,15 @@ sock_setsockopt(PySocketSockObject *s, P
27 /* setsockopt(level, opt, flag) */
28 if (PyArg_ParseTuple(args, "iii:setsockopt",
29 &level, &optname, &flag)) {
31 + buflen = sizeof flag;
32 + /* Multi cast options take shorter arguments */
33 + if (optname == IP_MULTICAST_TTL
34 + || optname == IP_MULTICAST_LOOP)
35 + buflen = sizeof(u_char);
37 res = setsockopt(s->sock_fd, level, optname,
38 - (char*)&flag, sizeof flag);
39 + (char*)&flag, buflen);
40 goto done;