Commit Graph

109 Commits

Author SHA1 Message Date
Fred Drake a04eaad5c7 Trent Mick <trentm@activestate.com>:
This patch fixes possible overflows in the socket module for 64-bit
platforms (mainly Win64). The changes are:

- abstract the socket type to SOCKET_T (this is SOCKET on Windows, int
on Un*x), this is necessary because sizeof(SOCKET) > sizeof(int) on
Win64

- use INVALID_SOCKET on Win32/64 for an error return value for
accept()

- ensure no overflow of the socket variable for: (1) a PyObject return
value (use PyLong_FromLongLong if necessary); and (2) printf
formatting in repr().

Closes SourceForge patch #100516.
2000-06-30 02:46:07 +00:00
Fred Drake 11b093641a Donn Cave <donn@oz.net>:
BeOS (up to 5.0) lacks <netinet/tcp.h>.
2000-05-16 13:30:12 +00:00
Guido van Rossum b18618dab7 Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.

(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode.  I'm also holding back on his
change to main.c, which seems unnecessary to me.)
2000-05-03 23:44:39 +00:00
Guido van Rossum 14f3f59d2b Fix typo in last patch -- the symbol's name is MSG_DONWAIT, not
MSG_DONTWAIT.  Reported by Fredrik Lundh.
2000-04-25 21:53:58 +00:00
Guido van Rossum 2c8bcb8794 Patch by Charles G Waldman:
1)  Adds MSG_DONTWAIT if defined (I needed this)
2)  Spells "coreectly" correctly ;-)
2000-04-25 21:34:53 +00:00
Guido van Rossum ff3ab42c04 Jack Jansen: The GUSI 2.0 I/O library used on the Mac uses the
socklen_t (unsigned int) for most size parameters.  Apparently this is
part of the UNIX 98 standard.

[GvR: the changes to configure.in etc. that I just checked in make
sure that socklen_t is defined everywhere, so I deleted the little
part of Jack's mod to define socklen_t if not in GUSI2.  I suppose I
will have to add it to the Windows config.h in a minute.]
2000-04-24 15:16:03 +00:00
Guido van Rossum 2dd8dddef4 Use an explicit macro SOCKETCLOSE which expands to closesocket (on
Windows), soclose (on OS2), or to close (everywhere else).

Hopefully this fixes a new compilation error that I suddenly get on
Windows because the macro definition for close -> closesocket
apparently was done before including io.h, which contains a prototype
for close.  (No idea why this wasn't an error before.)
2000-04-21 20:33:00 +00:00
Guido van Rossum fa972c987c In dealloc(), only close the socket if fd != -1. 2000-04-10 12:45:45 +00:00
Guido van Rossum b49dc75f51 Add warning that multi-arg connect() etc. are deprecated. 2000-04-04 15:09:07 +00:00
Guido van Rossum 527c9bd32a Put back multi-arg capability on connect/connect_ex/bind, for
backwards compatibility, and to avoid a revolution.
2000-04-04 14:10:20 +00:00
Andrew M. Kuchling 52a644cbda Add '#include <netinet/tcp.h>'
"man tcp" on Solaris says that TCP_NODELAY is defined in
netinet/tcp.h, and the Open Groups Unix98 spec agrees
(http://www.opengroup.org/onlinepubs/009619199/ninettcp.htm).
2000-03-31 17:24:30 +00:00
Guido van Rossum 27fc3c05e1 Fix all routines to use PyArg_ParseTuple(), and add ":name" to the
argument format strings.

THIS WILL PROBABLY BREAK LOTS OF CODE!!!

Also fixed a bogus string in an error message in getsockaddrlen().
2000-03-24 20:56:56 +00:00
Fred Drake e066134f48 Fixed inet_ntoa() docstring. 2000-03-07 14:05:16 +00:00
Guido van Rossum 43713e5a28 Massive patch by Skip Montanaro to add ":name" to as many
PyArg_ParseTuple() format string arguments as possible.
2000-02-29 13:59:29 +00:00
Guido van Rossum 09c8b6c3e4 OpenSSL support. This is based on patches for a version of SSLeay by
Brian E Gallew, which were improved and adapted to OpenSSL 0.9.4 by
Laszlo Kovacs of HP.  Both have kindly given permission to include
the patches in the Python distribution.  Final formatting by GvR.
1999-12-07 21:37:17 +00:00
Guido van Rossum 1b6e463bd5 Bugfix by Jack Jansen for Macintosh (for the inet_ntoa/aton changes):
<arpa/inet.h> doesn't exist and isn't needed; and inet_addr() returns
a structure containing a long rather than a long.
1999-11-04 18:22:29 +00:00
Guido van Rossum 9376b74c42 (1) On Linux, we really need to trust the configure script to select
the right variant of gethostbyname_r for us, since not all Linuxes are
equal in this respect.  Reported by Laurent Pointal.

(2) On BeOS, Chris Herborth reports that instead of arpa/inet.h you
must include net/netdb.h to get the inet_ntoa() and inet_addr()
prototypes.
1999-09-15 22:01:40 +00:00
Guido van Rossum a2e48552d2 It appears that inet_aton() doesn't really exist except in libresolv;
the proper function to call is inet_addr().  Since we already had code
to do that (for MS-Windows), this simplifies things a lot!
1999-09-09 15:42:59 +00:00
Guido van Rossum c6a164b8bc Port inet_ntoa and inet_aton to Windows:
- fix unescaped newline in string literal
- removed unused err variable
- Windows doesn't have inet_aton; use inet_addr instead
1999-08-20 19:11:27 +00:00
Guido van Rossum 5c9eb21729 Patch by Ben Gertzfield to add inet_aton() and inet_ntoa() calls. 1999-08-20 18:21:51 +00:00
Guido van Rossum 09be409220 Patch by Marc-Andre Lemburg to add a bunch more symbols. 1999-08-09 14:40:40 +00:00
Guido van Rossum 7a1229991d Put back __osf__ support for gethostbyname_r(); the real bug was that
it was being used even without threads.  This of course might be an
all-platform problem so now we only use the _r variant when we are
using threads.
1999-04-13 04:07:32 +00:00
Guido van Rossum cbf8906f5d 3-arg gethostbyname_r doesn't really work on OSF/1. 1999-04-10 15:46:01 +00:00
Guido van Rossum e7de2061b4 Implement two suggestions by Jonathan Giddy: (1) in AIX, clear the
data struct before calling gethostby{name,addr}_r(); (2) ignore the
3/5/6 args determinations made by the configure script and switch on
platform identifiers instead:

AIX, OSF have 3 args
Sun, SGI have 5 args
Linux has 6 args

On all other platforms, undef HAVE_GETHOSTBYNAME_R altogether.
1999-03-24 17:24:33 +00:00
Guido van Rossum 7b6c71f5a4 Vladimir Marangozov implements the AIX 3-arg gethostbyname_r code. 1999-03-24 17:20:40 +00:00
Guido van Rossum 3baaa1375b Clean up pass for the previous patches.
- Use HAVE_GETHOSTBYNAME_R_6_ARG instead of testing for Linux and
glibc2.

- If gethostbyname takes 3 args, undefine HAVE_GETHOSTBYNAME_R --
don't know what code should be used.

- New symbol USE_GETHOSTBYNAME_LOCK defined iff the lock should be used.

- Modify the gethostbyaddr() code to also hold on to the lock until
after it is safe to release, overlapping with the Python lock.

(Note: I think that it could in theory be possible that Python code
executed while gethostbyname_lock is held could attempt to reacquire
the lock -- e.g. in a signal handler or destructor.  I will simply say
"don't do that then.")
1999-03-22 21:44:51 +00:00
Guido van Rossum 955becc3d9 Jonathan Giddy writes:
Here's a patch to fix the race condition, which wasn't fixed by Rob's
patch.  It holds the gethostbyname lock until the results are copied out,
which means that this lock and the Python global lock are held at the same
time.  This shouldn't be a problem as long as the gethostbyname lock is
always acquired when the global lock is not held.
1999-03-22 20:14:53 +00:00
Guido van Rossum e9cd07b47f Patch by Rob Riggs for Linux -- glibc2 has a different argument
converntion for gethostbyname_r() etc. than Solaris!
1999-03-15 21:40:14 +00:00
Guido van Rossum 65d5b5763c Thanks to Chris Herborth, the thread primitives now have proper Py*
names in the source code (they already had those for the linker,
through some smart macros; but the source still had the old, un-Py names).
1998-12-21 19:32:43 +00:00
Guido van Rossum 3886bb6997 Add DL_EXPORT() to all modules that could possibly be used
on BeOS or Windows.
1998-12-04 18:50:17 +00:00
Guido van Rossum 7e48898d86 Use the t# format where appropriate. Greg Stein. 1998-10-08 02:25:24 +00:00
Guido van Rossum 49b560698b Renamed thread.h to pythread.h. 1998-10-01 20:42:43 +00:00
Guido van Rossum ce11393136 Remove some unused variables from gethostbyaddr_ex and gethostbyaddr,
discovered by Marc Lemburg.
1998-09-13 15:52:13 +00:00
Guido van Rossum 954e3cab0a Removed unused variables. 1998-08-06 03:21:15 +00:00
Guido van Rossum bcc207484a Changes for BeOS, QNX and long long, by Chris Herborth. 1998-08-04 22:53:56 +00:00
Guido van Rossum 7d896ab1bb Added gethostbyname_ex(), which returns the same kind of data as
gethostbyaddr().  (Plain gethostbyname() returns only the IP address.)
This moves the code shared by gethostbyaddr() and gethostbyname_ex()
to a subroutine.

Original patch by Dan Stromberg; some tweaks by GvR.
1998-08-04 22:16:43 +00:00
Guido van Rossum 82a5c66a51 Added copious docstrings, plus two minor layout tweaks. 1998-07-07 20:45:43 +00:00
Guido van Rossum 578de30fd7 Some systems (e.g. Linux) use enums for some symbols (like IPPROTO_IP)
so that our #ifdef test has the wrong effect.  Substitute hardcoded
values for some important symbols (but not for the whole range -- some
are pretty obscure so it's not worth it).
1998-05-28 20:18:18 +00:00
Guido van Rossum 4f199eaa6e Threading speedup patches by Christopher Lindblad <cjl@infoseek.com>. 1998-04-09 20:56:35 +00:00
Guido van Rossum 32c575da0a Left-aligned preprocessor directives and changed C++ comments to C
comments.
1997-12-02 20:37:32 +00:00
Guido van Rossum 8e9ebfd337 os2 patch by Jeff Rush 1997-11-22 21:53:48 +00:00
Barry Warsaw 0d2d759d8c PySocketSock_methods: Added "connect_ex" so the method can actually be
called!
1997-11-20 21:39:02 +00:00
Guido van Rossum fc4255db75 Add s.connect_ex() which returns errno instead of raising an exception. 1997-11-19 18:57:13 +00:00
Guido van Rossum 0cb96de269 Apply two changes, systematically:
(1) Use PyErr_NewException("module.class", NULL, NULL) to create the
    exception object.

(2) Remove all calls to Py_FatalError(); instead, return or
    ignore the errors -- the import code now checks PyErr_Occurred()
    after calling a module's init function, so it's no longer a
    fatal error for the initialization to fail.

Also did some small cleanups, e.g. removed unnecessary test for
"already initialized" from initfpectl(), and unified
initposix()/initnt().

I haven't checked this very thoroughly, so while the changes are
pretty trivial -- beware of untested code!
1997-10-01 04:29:29 +00:00
Guido van Rossum 91ba64ddd9 socket_type -> SocketType 1997-06-02 22:18:09 +00:00
Guido van Rossum 3b4b6fc602 Add socket.socket_type, as discussed on c.l.p. 1997-05-21 14:37:37 +00:00
Guido van Rossum fe28fa05e9 Remove the last three uses of PyArg_GetInt() from the source. 1997-05-15 19:09:26 +00:00
Guido van Rossum aa948df877 In makesockaddr(), if we don't know the address family, don't raise an
exception -- return it as a tuple.  Seems useful in promiscuous mode.
1997-05-07 17:41:48 +00:00
Guido van Rossum 644a12b00c Tweaks to keep the Microsoft compiler quier. 1997-04-09 19:24:53 +00:00
Barry Warsaw 752300bbdf Check of return values and proper error handling. 1997-01-03 17:18:10 +00:00