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


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

2015-09-30 Thread Angus Robertson - Magenta Systems Ltd
> As I say before - timeout will not works because ICS
> go to infinite loop in TCustomWSocket.AsyncReceive.

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

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