FFFTPのソースコードです。
Revisão | 92bf5e4c5bcb132cf15dc2b7098a9eba8713eb64 (tree) |
---|---|
Hora | 2011-09-12 00:58:55 |
Autor | s_kawamoto <s_kawamoto@user...> |
Commiter | s_kawamoto |
Bug fix of support for FTP over Explicit SSL/TLS (OpenSSL is required).
@@ -86,7 +86,8 @@ BOOL LoadOpenSSL() | ||
86 | 86 | || !(pSSL_read = (_SSL_read)GetProcAddress(g_hOpenSSL, "SSL_read")) |
87 | 87 | || !(pSSL_get_error = (_SSL_get_error)GetProcAddress(g_hOpenSSL, "SSL_get_error"))) |
88 | 88 | { |
89 | - FreeLibrary(g_hOpenSSL); | |
89 | + if(g_hOpenSSL) | |
90 | + FreeLibrary(g_hOpenSSL); | |
90 | 91 | g_hOpenSSL = NULL; |
91 | 92 | return FALSE; |
92 | 93 | } |
@@ -155,6 +156,8 @@ SSL** FindSSLPointerFromSocket(SOCKET s) | ||
155 | 156 | |
156 | 157 | void SetSSLTimeoutCallback(DWORD Timeout, LPSSLTIMEOUTCALLBACK pCallback) |
157 | 158 | { |
159 | + if(!g_bOpenSSLLoaded) | |
160 | + return; | |
158 | 161 | EnterCriticalSection(&g_OpenSSLLock); |
159 | 162 | g_OpenSSLTimeout = Timeout; |
160 | 163 | g_pOpenSSLTimeoutCallback = pCallback; |
@@ -166,6 +169,8 @@ BOOL AttachSSL(SOCKET s) | ||
166 | 169 | BOOL r; |
167 | 170 | DWORD Time; |
168 | 171 | SSL** ppSSL; |
172 | + if(!g_bOpenSSLLoaded) | |
173 | + return FALSE; | |
169 | 174 | r = FALSE; |
170 | 175 | Time = timeGetTime(); |
171 | 176 | EnterCriticalSection(&g_OpenSSLLock); |
@@ -207,6 +212,8 @@ BOOL DetachSSL(SOCKET s) | ||
207 | 212 | { |
208 | 213 | BOOL r; |
209 | 214 | SSL** ppSSL; |
215 | + if(!g_bOpenSSLLoaded) | |
216 | + return FALSE; | |
210 | 217 | r = FALSE; |
211 | 218 | EnterCriticalSection(&g_OpenSSLLock); |
212 | 219 | if(ppSSL = FindSSLPointerFromSocket(s)) |
@@ -223,6 +230,8 @@ BOOL DetachSSL(SOCKET s) | ||
223 | 230 | BOOL IsSSLAttached(SOCKET s) |
224 | 231 | { |
225 | 232 | SSL** ppSSL; |
233 | + if(!g_bOpenSSLLoaded) | |
234 | + return FALSE; | |
226 | 235 | EnterCriticalSection(&g_OpenSSLLock); |
227 | 236 | ppSSL = FindSSLPointerFromSocket(s); |
228 | 237 | LeaveCriticalSection(&g_OpenSSLLock); |
@@ -276,6 +285,8 @@ int closesocketS(SOCKET s) | ||
276 | 285 | int sendS(SOCKET s, const char * buf, int len, int flags) |
277 | 286 | { |
278 | 287 | SSL** ppSSL; |
288 | + if(!g_bOpenSSLLoaded) | |
289 | + return send(s, buf, len, flags); | |
279 | 290 | EnterCriticalSection(&g_OpenSSLLock); |
280 | 291 | ppSSL = FindSSLPointerFromSocket(s); |
281 | 292 | LeaveCriticalSection(&g_OpenSSLLock); |
@@ -287,6 +298,8 @@ int sendS(SOCKET s, const char * buf, int len, int flags) | ||
287 | 298 | int recvS(SOCKET s, char * buf, int len, int flags) |
288 | 299 | { |
289 | 300 | SSL** ppSSL; |
301 | + if(!g_bOpenSSLLoaded) | |
302 | + return recv(s, buf, len, flags); | |
290 | 303 | EnterCriticalSection(&g_OpenSSLLock); |
291 | 304 | ppSSL = FindSSLPointerFromSocket(s); |
292 | 305 | LeaveCriticalSection(&g_OpenSSLLock); |