Reputation: 21212
I am using this code to send emails via GMail (encrypted SMTP).
pocedure TForm5.SendEmail(const Recipients: string; const Subject: string; const Body: string);
var
Email: TIdMessage;
SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
Email := TIdMessage.Create(nil);
SSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
try
SSLHandler.MaxLineAction := maException;
SSLHandler.SSLOptions.Method := sslvSSLv23;
SSLHandler.SSLOptions.Mode := sslmUnassigned;
SSLHandler.SSLOptions.VerifyMode := [];
SSLHandler.SSLOptions.VerifyDepth := 0;
SMTP.IOHandler := SSLHandler;
SMTP.Host := 'smtp.gmail.com';
SMTP.Port := 587;
SMTP.Username := '[email protected]';
SMTP.Password := '**********';
SMTP.UseTLS := utUseExplicitTLS;
Email.From.Address := '[email protected]';
Email.Recipients.EmailAddresses := Recipients;
Email.Subject := Subject;
Email.Body.Text := Body;
SMTP.Connect;
if SMTP.Connected then
begin
SMTP.Send(Email);
SMTP.Disconnect;
end;
finally
Email.Free;
SSLHandler.Free;
end;
end;
The code is working from outside of Delphi IDE, but if ran from inside of the IDE it gives me an AV:
{Project Tester.exe raised exception class $C0000005 with message 'access violation at 0x7672bce7: read of address 0x675919d1'}
I have also tried to change SSLHandler.SSLOptions.Method, but with the same result.
The Call Stack
I don't know how I forgot to mention the strage thing about the AV: The AV in not in the code above. If I press 'Break' it shows the ASM window. The program stops in kernel32.IsBadReadPtr.
kernel32.IsBadReadPtr:
769CBCAB 6A0C push $0c
769CBCAD 6818BD9C76 push $769cbd18
769CBCB2 E8410F0100 call $769dcbf8
769CBCB7 A19460A576 mov eax,[$76a56094]
769CBCBC 8BB02C010000 mov esi,[eax+$0000012c]
769CBCC2 8B450C mov eax,[ebp+$0c]
769CBCC5 85C0 test eax,eax
769CBCC7 743F jz $769cbd08
769CBCC9 8B4D08 mov ecx,[ebp+$08]
769CBCCC 85C9 test ecx,ecx
769CBCCE 0F8437BC0200 jz $769f790b
769CBCD4 8D4401FF lea eax,[ecx+eax-$01]
769CBCD8 89450C mov [ebp+$0c],eax
769CBCDB 3BC1 cmp eax,ecx
769CBCDD 0F8228BC0200 jb $769f790b
769CBCE3 8365FC00 and dword ptr [ebp-$04],$00
769CBCE7 8A01 mov al,[ecx] <------------ HERE
769CBCE9 8D56FF lea edx,[esi-$01]
769CBCEC F7D2 not edx
769CBCEE 8BC2 mov eax,edx
769CBCF0 23C1 and eax,ecx
769CBCF2 8945E4 mov [ebp-$1c],eax
769CBCF5 21550C and [ebp+$0c],edx
769CBCF8 3B450C cmp eax,[ebp+$0c]
769CBCFB 0F85FBBB0200 jnz $769f78fc
...
The Call Stack is:
OnlineArmor is my firewall!!!!! I don't want to blame it so quickly... but is it possible it is the root if this AV?
I am using:
this SSL DLL: http://indy.fulgan.com/SSL/openssl-0.9.8r-i386-win32-rev2.zip
Delphi XE
Indy 10
Upvotes: 2
Views: 3188
Reputation: 21212
I solved this by uninstalling all bits of Online Armor. The code also works from Delphi now! Lesson not learned! Few years ago I had a similar problem with Kaspersky.
Thank you all for your suggestions. My mind was set on the fulgan DLL. It would have never crossed my mind to uninstall the firewall!
Upvotes: 0