• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Loweynet


コミットメタ情報

リビジョン69719d3c17c5e3f8810a4c5f3bde56229f5127fc (tree)
日時2012-06-02 00:24:44
作者s_kawamoto <s_kawamoto@user...>
コミッターs_kawamoto

ログメッセージ

Change OpenSSL context mode flags.

変更サマリ

差分

Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
--- a/socketwrapper.c
+++ b/socketwrapper.c
@@ -39,6 +39,7 @@ typedef long (__cdecl* _SSL_get_verify_result)(const SSL*);
3939 typedef SSL_SESSION* (__cdecl* _SSL_get_session)(SSL*);
4040 typedef int (__cdecl* _SSL_set_session)(SSL*, SSL_SESSION*);
4141 typedef X509_STORE* (__cdecl* _SSL_CTX_get_cert_store)(const SSL_CTX*);
42+typedef long (__cdecl* _SSL_CTX_ctrl)(SSL_CTX*, int, long, void*);
4243 typedef BIO_METHOD* (__cdecl* _BIO_s_mem)();
4344 typedef BIO* (__cdecl* _BIO_new)(BIO_METHOD*);
4445 typedef int (__cdecl* _BIO_free)(BIO*);
@@ -72,6 +73,7 @@ _SSL_get_verify_result p_SSL_get_verify_result;
7273 _SSL_get_session p_SSL_get_session;
7374 _SSL_set_session p_SSL_set_session;
7475 _SSL_CTX_get_cert_store p_SSL_CTX_get_cert_store;
76+_SSL_CTX_ctrl p_SSL_CTX_ctrl;
7577 _BIO_s_mem p_BIO_s_mem;
7678 _BIO_new p_BIO_new;
7779 _BIO_free p_BIO_free;
@@ -144,7 +146,8 @@ BOOL LoadOpenSSL()
144146 || !(p_SSL_get_verify_result = (_SSL_get_verify_result)GetProcAddress(g_hOpenSSL, "SSL_get_verify_result"))
145147 || !(p_SSL_get_session = (_SSL_get_session)GetProcAddress(g_hOpenSSL, "SSL_get_session"))
146148 || !(p_SSL_set_session = (_SSL_set_session)GetProcAddress(g_hOpenSSL, "SSL_set_session"))
147- || !(p_SSL_CTX_get_cert_store = (_SSL_CTX_get_cert_store)GetProcAddress(g_hOpenSSL, "SSL_CTX_get_cert_store")))
149+ || !(p_SSL_CTX_get_cert_store = (_SSL_CTX_get_cert_store)GetProcAddress(g_hOpenSSL, "SSL_CTX_get_cert_store"))
150+ || !(p_SSL_CTX_ctrl = (_SSL_CTX_ctrl)GetProcAddress(g_hOpenSSL, "SSL_CTX_ctrl")))
148151 {
149152 if(g_hOpenSSL)
150153 FreeLibrary(g_hOpenSSL);
@@ -345,7 +348,10 @@ BOOL SetSSLRootCertificate(const void* pData, DWORD Length)
345348 r = FALSE;
346349 EnterCriticalSection(&g_OpenSSLLock);
347350 if(!g_pOpenSSLCTX)
351+ {
348352 g_pOpenSSLCTX = p_SSL_CTX_new(p_SSLv23_method());
353+ p_SSL_CTX_ctrl(g_pOpenSSLCTX, SSL_CTRL_MODE, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_AUTO_RETRY, NULL);
354+ }
349355 if(g_pOpenSSLCTX)
350356 {
351357 if(pStore = p_SSL_CTX_get_cert_store(g_pOpenSSLCTX))
@@ -450,7 +456,10 @@ BOOL AttachSSL(SOCKET s, SOCKET parent, BOOL* pbAborted)
450456 Time = timeGetTime();
451457 EnterCriticalSection(&g_OpenSSLLock);
452458 if(!g_pOpenSSLCTX)
459+ {
453460 g_pOpenSSLCTX = p_SSL_CTX_new(p_SSLv23_method());
461+ p_SSL_CTX_ctrl(g_pOpenSSLCTX, SSL_CTRL_MODE, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_AUTO_RETRY, NULL);
462+ }
454463 if(g_pOpenSSLCTX)
455464 {
456465 if(ppSSL = GetUnusedSSLPointer())
@@ -611,6 +620,7 @@ int FTPS_closesocket(SOCKET s)
611620 // send相当の関数
612621 int FTPS_send(SOCKET s, const char * buf, int len, int flags)
613622 {
623+ int r;
614624 SSL** ppSSL;
615625 if(!g_bOpenSSLLoaded)
616626 return send(s, buf, len, flags);
@@ -619,12 +629,16 @@ int FTPS_send(SOCKET s, const char * buf, int len, int flags)
619629 LeaveCriticalSection(&g_OpenSSLLock);
620630 if(!ppSSL)
621631 return send(s, buf, len, flags);
622- return p_SSL_write(*ppSSL, buf, len);
632+ r = p_SSL_write(*ppSSL, buf, len);
633+ if(r < 0)
634+ return SOCKET_ERROR;
635+ return r;
623636 }
624637
625638 // recv相当の関数
626639 int FTPS_recv(SOCKET s, char * buf, int len, int flags)
627640 {
641+ int r;
628642 SSL** ppSSL;
629643 if(!g_bOpenSSLLoaded)
630644 return recv(s, buf, len, flags);
@@ -634,8 +648,12 @@ int FTPS_recv(SOCKET s, char * buf, int len, int flags)
634648 if(!ppSSL)
635649 return recv(s, buf, len, flags);
636650 if(flags & MSG_PEEK)
637- return p_SSL_peek(*ppSSL, buf, len);
638- return p_SSL_read(*ppSSL, buf, len);
651+ r = p_SSL_peek(*ppSSL, buf, len);
652+ else
653+ r = p_SSL_read(*ppSSL, buf, len);
654+ if(r < 0)
655+ return SOCKET_ERROR;
656+ return r;
639657 }
640658
641659 // IPv6対応