Re: [twsocket] Serious bug in SmtpCli/TWSocket: infinite loop

2015-10-02 Thread Angus Robertson - Magenta Systems Ltd
> This server responding but incorrectly ! 
> After connect they return just array of zeroes #0 without any data.

This is now fixed, but needs more testing before I commit it to SVN.
 
> This will works only for Smtp protocol. But I think it's should be 
> fixed on TWSocket level to fix possible problems with all remaining 
> protocols.

We have a long term problem with ICS, that different protocol components were
written and updated at different times, often using differing techniques.

For instance, most protocols use ASCII command lines and TWSocket offers 
LineMode to
return simple lines, and yet many protocols have their own line parsing code
duplicating LineMode, but not always successfully as with your bad server.  

I used LineMode for the SMTP server, and the HTTP client uses it for commands 
(but
changes back to binary for bodies), but the SMTP, POP3 and FTP clients don't 
use it
and all have different line parsing functions.  

I guess the reason the protocols were not updated to LineMode is not wanting to
change something that works.  But sometimes the benefit of a change are 
justified by
increasing reliability, as with your bad server, where the data is simply 
ignored
and the remote server drops the connection.  

I'll also update the POP3 client, since I'm updating two of my own applications 
that
send and receive email, and I can test the changes easily.

Angus
 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Serious bug in SmtpCli/TWSocket: infinite loop

2015-09-30 Thread Angus Robertson - Magenta Systems Ltd
> Just found serious problem of TWSocket/TSmtpCli:
> infinite loop around DoRecv/DataAvailable in TWSocket !
> It's happens only with some misconfigured/buggy MX servers.
> Yes, nmact1.nmact.org is misconfigured (i check it using sniffer - 
> they return 4096 bytes of
> zeroes (\0) as reply) but ICS should handle all situations anyway.

If the remote SMTP server does not respond to commands, nothing will work.  I'll
make sure there is a timeout or something.

Angus

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Serious bug in SmtpCli/TWSocket: infinite loop

2015-09-30 Thread Max Terentiev
Hi,

> And I said illegal characters should be ignored, just in a different
> way to your check for illegal characters.

Yes, ofcource. But it's should be done in ICS. Because of infinite loop
OnRequestDone never triggered so, it's not possible to handle illegal
character in my code.

---
With best regards, Max Terentiev.
Business Software Products.
AMS Development Team.
supp...@bspdev.com


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Serious bug in SmtpCli/TWSocket: infinite loop

2015-09-30 Thread Max Terentiev
Hi,

This server responding but incorrectly ! 
After connect they return just array of zeroes #0 without any data.

This cause infinite loop in TCustomWSocket.AsyncReceive !

Timeout will not works - events not comes because of 100% cpu
usage in infinite loop.

Exactly this server nmact1.nmact.org hangs MailSnd demo immediately
after Connect so you can only kill the process.

I fixed it by adding this lines to TCustomSmtpClient.WSocketDataAvailable:

if(FState=smtpWaitingBanner) and (Len>0) and
(FReceiveBuffer[0]=AnsiChar(#0))  then
   begin
   FLastResponse:='unexpected server reply';
   SetErrorMessage;
   FRequestResult := 500;
   TriggerRequestDone(500);
   Exit;
   end;

This will works only for Smtp protocol. But I think it's should be fixed
on TWSocket level to fix possible problems with all remaining protocols.

---
With best regards, Max Terentiev.
Business Software Products.
AMS Development Team.
supp...@bspdev.com

> -Original Message-
> From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of
> Angus Robertson - Magenta Systems Ltd
> Sent: Wednesday, September 30, 2015 9:56 AM
> To: twsocket@lists.elists.org
> Subject: Re: [twsocket] Serious bug in SmtpCli/TWSocket: infinite loop
> 
> > Just found serious problem of TWSocket/TSmtpCli:
> > infinite loop around DoRecv/DataAvailable in TWSocket !
> > It's happens only with some misconfigured/buggy MX servers.
> > Yes, nmact1.nmact.org is misconfigured (i check it using sniffer -
> > they return 4096 bytes of zeroes (\0) as reply) but ICS should handle
> > all situations anyway.
> 
> If the remote SMTP server does not respond to commands, nothing will
> work.  I'll make sure there is a timeout or something.
> 
> Angus
> 
> --
> To unsubscribe or change your settings for TWSocket mailing list please
> goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Serious bug in SmtpCli/TWSocket: infinite loop

2015-09-30 Thread Angus Robertson - Magenta Systems Ltd
> This server responding but incorrectly ! 

There was no valid banner response, so a timeout is a valid concept.

> After connect they return just array of zeroes #0 without any data.

Which should be ignored, but might have been followed by valid commands.  
 
Angus

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Serious bug in SmtpCli/TWSocket: infinite loop

2015-09-30 Thread Max Terentiev
Hi,

As I say before - timeout will not works because ICS
go to infinite loop in TCustomWSocket.AsyncReceive.

No way to interrupt it because infinite loop eat 100%
cpu, program stop responding and timer events not works.

Only way is killing process !

Just start \Samples\Delphi\MailNewsDemos\OverbyteIcsMailSnd.dpr
Enter nmact1.nmact.org as Smtp host and press Connect button.

Demo will stop responding immediately and you can only kill the process !

---
With best regards, Max Terentiev.
Business Software Products.
AMS Development Team.
supp...@bspdev.com

> -Original Message-
> From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of
> Angus Robertson - Magenta Systems Ltd
> Sent: Wednesday, September 30, 2015 1:16 PM
> To: twsocket@lists.elists.org
> Subject: Re: [twsocket] Serious bug in SmtpCli/TWSocket: infinite loop
> 
> > This server responding but incorrectly !
> 
> There was no valid banner response, so a timeout is a valid concept.
> 
> > After connect they return just array of zeroes #0 without any data.
> 
> Which should be ignored, but might have been followed by valid
> commands.
> 
> Angus
> 
> --
> To unsubscribe or change your settings for TWSocket mailing list please
> goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be