You are not logged in.
Pages: 1
Hi,
I have encountered an odd issue with InitSocketInterface when used under Win64, it can combine to trigger a Windows bug in ResolveNameToIP, the bug in question is the same as in the stackoverflow post (https://stackoverflow.com/questions/215 … it-windows), you can end up with "DEADF00D" in the result in Win64 because of a Windows bug in deprecated GetHostByName function.
The issue is that when InitSocketInterface is called twice, while the LoadLibrary stuff is protected by SynSockCount, the SockEnhancedApi variable is not, it is reset to False, so instead of using the GetAddrInfo API, it is the GetHostByName that is being called, which sometimes bugs in Win64.
Offline
For a patch, if you want to restrict support to Windows 8.1 and Windows Server 2012 R2, the cleanest option would simply be to remove SockEnhancedApi and all accompanying code (either for all versions, or just for Win64).
If you still want to support the legacy API, I guess the "SockEnhancedApi := False;" could be moved within the "if SynSockCount = 0 then begin" (and same with SockSChannelApi)
function InitSocketInterface(const Stack: TFileName = ''): Boolean;
begin
result := False;
EnterCriticalSection(SynSockCS);
try
if SynSockCount = 0 then begin
SockEnhancedApi := False;
SockSChannelApi := False;
SockWship6Api := False;
if Stack = '' then
LibHandle := LoadLibrary(DLLStackName)
else
But since there were explicitly left outside of the "if SynSockCount = 0" I guess there may be side effects ?
Last edited by Eric (2018-06-07 14:36:22)
Offline
I don't understand why InitSocketInterface() should be called twice?
It is executed in the initialization section of SynCrtSock, and that's all...
Anyway, I've patched the function as https://synopse.info/fossil/info/5924b5bc17
Offline
I don't understand why InitSocketInterface() should be called twice?
It is executed in the initialization section of SynCrtSock, and that's all...Anyway, I've patched the function as https://synopse.info/fossil/info/5924b5bc17
Thanks!
The reason it's called twice is I have some units and projects using only SynWinSock, so they have their own call InitSocketInterface, and when used in projects that also use SynCrtSock, then InitSocketInterface gets called twice.
If it's not meant to be called more than once, I guess the SynSockCount mechanism could be removed, and the initialization performed directly by SynWinSock ?
Offline
Pages: 1