[Python-bugs-list] [Bug #111620] lots of use of send() without verifying amount of data sent.

noreply@sourceforge.net noreply@sourceforge.net
Fri, 11 Aug 2000 07:48:54 -0700


Bug #111620, was updated on 2000-Aug-10 16:39
Here is a current snapshot of the bug.

Project: Python
Category: Library
Status: Closed
Resolution: Wont Fix
Bug Group: None
Priority: 5
Summary: lots of use of send() without verifying amount of data sent.

Details: a quick grep of the standard python library (below) shows that there
is lots of unchecked use of the send() function.  Every unix system I've every used states that send() returns the number of bytes sent, which can be < length(<string>).  Using socket.send(s) without verifying that the return value is equal to the length of s is careless and can result in loss of data.

I just submitted a patch for smtplib's use of send(), have patched a piece of Zope the same way, and get the feeling that it's becoming standard to call send() without checking 
that the amount of data sent is the intended amount.  While this is OK for a quick script, I don't feel it's OK for library code or anything that might be used in production.

scott

Follow-Ups:

Date: 2000-Aug-11 07:23
By: twouters

Comment:
As Guido and Fred pointed out on python-dev, you are confusing 'send()' with 'write()'. 'send()' either returns an error code (when the message is too large) or succeeds. It doesn't do half-writes.

-------------------------------------------------------

Date: 2000-Aug-11 07:48
By: gvanrossum

Comment:
(And I'm not so sure that write() can do partial writes either!)
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=111620&group_id=5470