[Mono-bugs] [Bug 626164] System.Net.Mail.SmtpClient sometimes silently drops messages on the floor

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Jul 31 20:29:40 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=626164

http://bugzilla.novell.com/show_bug.cgi?id=626164#c4


--- Comment #4 from David Barts <n5jrn at mac.com> 2010-08-01 00:29:38 UTC ---
I've been looking at the source in
mcs/class/System/System.Net.Mail/SmtpClient.cs and frankly it looks like
something of a mess.

There's three separate objects being used to interact with the TCP socket: a
Stream, a StreamReader, and a StreamWriter. All are directly used for I/O. From
what I've noticed, pains are being taken to flush the StreamWriter after it is
used. But the StreamReader worries me; might not its buffering be causing the
reading of responses to get out of sync? That could explain why emails
mysteriously get dropped on the floor. Some other bugs are garbling the message
or the SMTP commands, the remote server is taking offense and sending an error
reply, but we never get to notice it and throw an exception back to the calling
code.

If I were coding this class, I would have just used the StreamReader and the
StreamWriter objects, and never touched the Stream one. Mixing the use of the
two seems to me to be just asking for headaches caused by buffering.

The code to read the SMTP responses seems very convoluted (Read method starting
at line 361 in the most current version of SmtpClient.cs). I can't help but
suspect there might be a bug or two lurking in there, even though I've tried
working through it and haven't yet found one.

The code to write the message body to the remote server (SendData method
starting at line 719) does definitely have a bug. It only transforms a "." line
to a ".." one. According to RFC2821, all lines that start with a "." should
have an extra "." prepended to, not just bare "." lines. It also does some
pretty convoluted processing to detect those "." lines. They're already strings
at this stage, so the code should just use .StartsWith(".") and forget about
trying to manually loop through the string.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list