summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-37811: FreeBSD, OSX: fix poll(2) usage in sockets module (GH-15202)Miss Islington (bot)2019-08-141-0/+11
| | | | | | | | | | | | | | | | | | | FreeBSD implementation of poll(2) restricts the timeout argument to be either zero, or positive, or equal to INFTIM (-1). Unless otherwise overridden, socket timeout defaults to -1. This value is then converted to milliseconds (-1000) and used as argument to the poll syscall. poll returns EINVAL (22), and the connection fails. This bug was discovered during the EINTR handling testing, and the reproduction code can be found in https://bugs.python.org/issue23618 (see connect_eintr.py, attached). On GNU/Linux, the example runs as expected. This change is trivial: If the supplied timeout value is negative, truncate it to -1. (cherry picked from commit 28146206578ebe1b84b48e6f255738a227058c04) Co-authored-by: Artem Khramov <akhramov@pm.me>
* [3.7] bpo-36254: Fix invalid uses of %d in format strings in C. (GH-12264). ↵Serhiy Storchaka2019-03-141-2/+2
| | | | | | | (GH-12322) (cherry picked from commit d53fe5f407ff4b529628b01a1bcbf21a6aad5c3a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-35550: Fix incorrect Solaris define guards (GH-11275)Miss Islington (bot)2018-12-311-1/+1
| | | | | | | | | | Python source code uses on several places ifdef sun or defined(sun) without the underscores, which is not standard compliant and shouldn't be used. Defines should check for __sun instead. Reference: http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_systemGH-Solaris https://bugs.python.org/issue35550 (cherry picked from commit 6f9bc72c79c3262e5d0f2c0e96b016477399cfb1) Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
* bpo-35214: MSan workarounds for socket, time, and test_faulthandler. ↵Miss Islington (bot)2018-12-311-0/+20
| | | | | | | | | | (GH-11375) (GH-11378) Add Clang Memory Sanitizer build instrumentation to work around false positives from the socket and time modules as well as skipping a couple test_faulthandler tests. (cherry picked from commit b474e6774d60fa67d5373e361a0ed53c18b24f53) Co-authored-by: Gregory P. Smith <greg@krypto.org>
* bpo-35454: Fix miscellaneous minor issues in error handling. (GH-11077)Miss Islington (bot)2018-12-111-4/+8
| | | | | | | | * bpo-35454: Fix miscellaneous minor issues in error handling. * Fix a null pointer dereference. (cherry picked from commit 8905fcc85a6fc3ac394bc89b0bbf40897e9497a6) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-35050: AF_ALG length check off-by-one error (GH-10058) (GH-11069)Victor Stinner2018-12-101-3/+7
| | | | | | | | | The length check for AF_ALG salg_name and salg_type had a off-by-one error. The code assumed that both values are not necessarily NULL terminated. However the Kernel code for alg_bind() ensures that the last byte of both strings are NULL terminated. Signed-off-by: Christian Heimes <christian@python.org> (cherry picked from commit 2eb6ad8578fa9d764c21a92acd8e054e3202ad19)
* Fix a possible reference leak in _socket.getaddrinfo(). (GH-10543)Miss Islington (bot)2018-11-151-2/+4
| | | | | | "single" needs to be decrefed if PyList_Append() fails. (cherry picked from commit 4c596d54aa6a55e9d2a3db78891e656ebbfb63c8) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* [3.7] closes bpo-25041: Document AF_PACKET socket address format. (GH-9207)Benjamin Peterson2018-09-121-3/+3
| | | | | (cherry picked from commit 731ff68eeef58babdf2b32dc9a73b141760c2be9) Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
* closes bpo-34581 : Conditionalize use of __pragma in Modules/socketmodule.c. ↵Miss Islington (bot)2018-09-051-2/+5
| | | | | | | (GH-9067) (cherry picked from commit 874809ea389e6434787e773a6054a08e0b81f734) Co-authored-by: Erik Janssens <erik.janssens@conceptive.be>
* bpo-34217: Use lowercase for windows headers (GH-8472)Miss Islington (bot)2018-08-161-1/+1
| | | | | (cherry picked from commit e6a4755e6793942b950c1595e0c34bd66a0ee13e) Co-authored-by: Erik Janssens <erik.janssens@conceptive.be>
* bpo-32394: Remove some TCP options on old version Windows. (GH-5523)Miss Islington (bot)2018-02-261-0/+70
| | | | | (cherry picked from commit 19e7d48ce89422091f9af93038b9fee075d46e9e) Co-authored-by: animalize <animalize@users.noreply.github.com>
* bpo-32221: makeipaddr(): remove interface part + speedup (GH-5449) (GH-5449) ↵Miss Islington (bot)2018-02-121-28/+31
| | | | | | | (#5641) (cherry picked from commit 7766b96ab80b04509bbac708ee5ecf3c1c5934fc) Co-authored-by: Коренберг Марк <socketpair@gmail.com>
* Fix some warnings produced by different compilers. (GH-5593) (GH-5600)Miss Islington (bot)2018-02-091-2/+6
| | | | | (cherry picked from commit bfe4fd5f2e96e72eecb5b8a0c7df0ac1689f3b7e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.7] bpo-32746: Fix multiple typos (GH-5144) (GH-5520)Miss Islington (bot)2018-02-041-1/+1
| | | | | | Fix typos found by codespell in docs, docstrings, and comments. (cherry picked from commit c3d9508ff22ece9a96892b628dd5813e2fb0cd80) Co-authored-by: Leo Arias <leo.arias@canonical.com>
* bpo-28134: Auto-detect socket values from file descriptor (#1349)Christian Heimes2018-01-291-2/+69
| | | | | | | | | | | | | | | Fix socket(fileno=fd) by auto-detecting the socket's family, type, and proto from the file descriptor. The auto-detection can be overruled by passing in family, type, and proto explicitly. Without the fix, all socket except for TCP/IP over IPv4 are basically broken: >>> s = socket.create_connection(('www.python.org', 443)) >>> s <socket.socket fd=3, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('2003:58:bc4a:3b00:56ee:75ff:fe47:ca7b', 59730, 0, 0), raddr=('2a04:4e42:1b::223', 443, 0, 0)> >>> socket.socket(fileno=s.fileno()) <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('2003:58:bc4a:3b00::%2550471192', 59730, 0, 2550471192), raddr=('2a04:4e42:1b:0:700c:e70b:ff7f:0%2550471192', 443, 0, 2550471192)> Signed-off-by: Christian Heimes <christian@python.org>
* bpo-32373: Add socket.getblocking() method. (#4926)Yury Selivanov2018-01-281-1/+48
|
* Revert "bpo-32221: makeipaddr(): remove interface part + speedup (GH-4724)" ↵Yury Selivanov2018-01-281-31/+28
| | | | | (#5394) This reverts commit 47c0b1f7d4115e6f15e6776c1f91d28e7d96fe0c.
* bpo-32221: makeipaddr(): remove interface part + speedup (GH-4724)Коренберг Марк2018-01-271-28/+31
|
* bpo-32454: socket closefd (#5048)Christian Heimes2018-01-271-2/+29
| | | | | Add close(fd) function to the socket module Signed-off-by: Christian Heimes <christian@python.org>
* bpo-32282: Remove unnecessary check for `VersionHelpers.h` in ↵Max Bélanger2018-01-071-10/+0
| | | | `socketmodule.c` on Windows
* bpo-32331: Fix socket.type when SOCK_NONBLOCK is available (#4877)Yury Selivanov2017-12-191-6/+15
|
* bpo-31927: Fix bugs in socketmodule.c on NetBSD and other issues. (#4235)Serhiy Storchaka2017-11-091-64/+67
| | | | | | | * Fix compilation of the socket module on NetBSD 8. * Fix the assertion failure or reading arbitrary data when parse a AF_BLUETOOTH address on NetBSD and DragonFly BSD. * Fix other potential errors and make the code more reliable.
* Fix miscellaneous typos (#4275)luzpaz2017-11-051-1/+1
|
* bpo-16135: Cleanup: Code rot left over from OS/2 support (GH-4147)Erik Bray2017-10-271-7/+0
| | | | Remove dangling references to PYCC_VACPP that are not relelvant since removal of OS/2 support.
* Fix _socket module compilation on Cygwin. (#4137)Erik Bray2017-10-271-1/+1
|
* bpo-31806: Use _PyTime_ROUND_TIMEOUT for the timeout argument parsing in ↵Pablo Galindo2017-10-181-3/+3
| | | | | | | | | more functions (#4026) Fix timeout rounding in time.sleep(), threading.Lock.acquire() and socket.socket.settimeout() to round correctly negative timeouts between -1.0 and 0.0. The functions now block waiting for events as expected. Previously, the call was incorrectly non-blocking.
* Remove a null statement that was necessary for --without-threads (#3478)Zackery Spytz2017-09-111-1/+0
|
* bpo-31393: Fix the use of PyUnicode_READY(). (#3451)Serhiy Storchaka2017-09-081-1/+4
|
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-12/+2
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-27584: New addition of vSockets to the python socket module (#2489)caavery2017-09-061-2/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bpo-27584: New addition of vSockets to the python socket module Support for AF_VSOCK on Linux only * bpo-27584: Fixes for V2 Fixed syntax and naming problems. Fixed #ifdef AF_VSOCK checking Restored original aclocal.m4 * bpo-27584: Fixes for V3 Added checking for fcntl and thread modules. * bpo-27584: Fixes for V4 Fixed white space error * bpo-27584: Fixes for V5 Added back comma in (CID, port). * bpo-27584: Fixes for V6 Added news file. socket.rst now reflects first Linux introduction of AF_VSOCK. Fixed get_cid in test_socket.py. Replaced PyLong_FromLong with PyLong_FromUnsignedLong in socketmodule.c Got rid of extra AF_VSOCK #define. Added sockaddr_vm to sock_addr. * bpo-27584: Fixes for V7 Minor cleanup. * bpo-27584: Fixes for V8 Put back #undef AF_VSOCK as it is necessary when vm_sockets.h is not installed.
* remove IRIX support (closes bpo-31341) (#3310)Benjamin Peterson2017-09-041-4/+2
| | | See PEP 11.
* bpo-30987 - Support for ISO-TP protocol in SocketCAN (#2956)Pier-Yves Lessard2017-08-281-5/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added support for CAN_ISOTP protocol * Added unit tests for CAN ISOTP * Updated documentation for ISO-TP protocol * Removed trailing whitespace in documentation * Added blurb NEWS.d file * updated Misc/ACKS * Fixed broken unit test that was using isotp const outside of skippable section * Removed dependecy over third party project * Added implementation for getsockname + unit tests * Missing newline at end of ACKS file * Accidentally inserted a type in ACKS file * Followed tiran changes review #1 recommendations * Added spaces after comma
* bpo-28261: Fixed err msgs where PyArg_ParseTuple is used to parse normal ↵Oren Milman2017-08-201-2/+4
| | | | tuples. (#3119)
* bpo-30319: socket.close() now ignores ECONNRESET (#2565)Victor Stinner2017-07-041-1/+3
| | | | socket.close() was modified in Python 3.6 to raise OSError on failure: see bpo-26685.
* bpo-23451: Fix socket deprecation warnings in socketmodule.c (#2318)Segev Finer2017-06-281-171/+16
| | | | | | | | | | | | | | | | | | * bpo-23451: Fix WSASocket and WSADuplicateSocket deprecation warnings * bpo-23451: Add backwards compatibility note about socket share/fromshare * bpo-23451: Fixed `WSAAddressToString`/`WSAStringToAddress` deprecation warnings * bpo-23451: Use `inet_pton`/`inet_ntop` instead of `WSAAddressToString`/`WSAStringToAddress` * bpo-23451: Move `HAVE_INET_PTON` from _socket.vcxproj to pyconfig.h * bpo-23451: Add SUPPRESS_DEPRECATED_CALL to socketmodule.c * bpo-23451: Add a NEWS.d entry * bpo-23451: Corrected NEWS.d entry
* bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux (#1370)Antoine Pitrou2017-05-021-3/+3
| | | | | | * bpo-30205: Fix getsockname() for unbound AF_UNIX sockets on Linux * Add NEWS entry
* bpo-29728: Provide socket.TCP_NOTSENT_LOWAT (#477)Nathaniel J. Smith2017-03-231-0/+3
| | | | | * Provide socket.TCP_NOTSENT_LOWAT * New TCP option available on recent MacOS and Linux. * Document addition of TCP_NOTSENT_LOWAT
* Add sockaddr_alg to sock_addr_t (#234)Christian Heimes2017-02-221-30/+0
| | | | | | | | | | sock_addr_t is used to define the minimum size of any socket address on the stack. Let's make sure that an AF_ALG address always fits. Coverity complains because in theory, AF_ALG might be larger than any of the other structs. In practice it already fits. Closes Coverity CID 1398948, 1398949, 1398950 Signed-off-by: Christian Heimes <christian@python.org>
* Remove double definition of IPPROTO_IPV6 (#100)Maximilian Hils2017-02-141-3/+0
| | | IPPROTO_IPV6 is already defined further above in the same way.
* Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka2017-01-231-16/+8
| | | | possible. Patch is writen with Coccinelle.
* Address a minor Coverity warning re: unchecked PyArg_ParseTuple callsGregory P. Smith2017-01-181-5/+7
| | | | | in socket.sendto(). A PyErr_Occurred() check was happening later, but it is better to just use the return value and not call PyErr_Occurred().
* Add TCP_CONGESTION and TCP_USER_TIMEOUTVictor Stinner2016-11-291-0/+6
| | | | | | | Issue #26273: Add new socket.TCP_CONGESTION (Linux 2.6.13) and socket.TCP_USER_TIMEOUT (Linux 2.6.37) constants. Patch written by Omar Sandoval.
* Added the const qualifier to char* variables that refer to readonly internalSerhiy Storchaka2016-11-201-1/+1
| | | | UTF-8 represenatation of Unicode objects.
* Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSizeSerhiy Storchaka2016-11-201-1/+1
|\ | | | | | | with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
| * Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSizeSerhiy Storchaka2016-11-201-1/+1
| | | | | | | | with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
* | Merge AIX fixes from 3.6Martin Panter2016-11-141-1/+3
|\ \ | |/
| * Merge AIX fixes from 3.5 into 3.6Martin Panter2016-11-141-1/+3
| |\
| | * Issue #28000: Fix gethostbyname_r() usage on AIX with _LINUX_SOURCE_COMPATMartin Panter2016-11-141-1/+3
| | | | | | | | | | | | Patch by Matthieu S.
* | | Issue #28480: Merge multithreading fixes from 3.6Martin Panter2016-10-201-0/+1
|\ \ \ | |/ /
| * | Issue #28480: Avoid label at end of compound statement --without-threadsMartin Panter2016-10-201-0/+1
| | | | | | | | | | | | Based on patch by Masayuki Yamamoto.