• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

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

Loweynet


Commit MetaInfo

Revision98a8ff5f501726ce2f71296138ab21e98eb68173 (tree)
Zeit2011-10-13 19:16:56
Autors_kawamoto <s_kawamoto@user...>
Commiters_kawamoto

Log Message

Fix bugs of file deletion code on transfer thread (but it is unused).
Fix bugs on trying encrypted connection.
Remove log size limit for Windows 9x.

Ändern Zusammenfassung

Diff

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/common.h
+++ b/common.h
@@ -921,6 +921,7 @@ typedef struct {
921921 char DialEntry[RAS_NAME_LEN+1]; /* ダイアルアップエントリ */
922922 // 暗号化通信対応
923923 int CryptMode; /* 暗号化通信モード (CRYPT_xxx) */
924+ int UseNoEncryption; /* 暗号化なしで接続する (YES/NO) */
924925 int UseFTPES; /* FTPESで接続する (YES/NO) */
925926 int UseFTPIS; /* FTPISで接続する (YES/NO) */
926927 int UseSFTP; /* SFTPで接続する (YES/NO) */
--- a/connect.c
+++ b/connect.c
@@ -57,7 +57,10 @@ static int SendInitCommand(char *Cmd);
5757 static void AskUseFireWall(char *Host, int *Fire, int *Pasv, int *List);
5858 static void SaveCurrentSetToHistory(void);
5959 static int ReConnectSkt(SOCKET *Skt);
60-static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);
60+// 暗号化通信対応
61+//static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);
62+static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);
63+static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security);
6164 static int CheckOneTimePassword(char *Pass, char *Reply, int Type);
6265 static BOOL CALLBACK BlkHookFnc(void);
6366 static int Socks5MakeCmdPacket(SOCKS5REQUEST *Packet, char Cmd, int ValidIP, ulong IP, char *Host, ushort Port);
@@ -159,7 +162,9 @@ void ConnectProc(int Type, int Num)
159162 Save = YES;
160163
161164 DisableUserOpe();
162- CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security);
165+ // 暗号化通信対応
166+// CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security);
167+ CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, Save, CurHost.Security);
163168 TrnCtrlSocket = CmdCtrlSocket;
164169
165170 if(CmdCtrlSocket != INVALID_SOCKET)
@@ -238,7 +243,9 @@ void QuickConnectProc(void)
238243 SetSyncMoveMode(CurHost.SyncMove);
239244
240245 DisableUserOpe();
241- CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);
246+ // 暗号化通信対応
247+// CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);
248+ CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);
242249 TrnCtrlSocket = CmdCtrlSocket;
243250
244251 if(CmdCtrlSocket != INVALID_SOCKET)
@@ -410,7 +417,9 @@ void DirectConnectProc(char *unc, int Kanji, int Kana, int Fkanji, int TrMode)
410417 }
411418
412419 DisableUserOpe();
413- CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);
420+ // 暗号化通信対応
421+// CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);
422+ CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);
414423 TrnCtrlSocket = CmdCtrlSocket;
415424
416425 if(CmdCtrlSocket != INVALID_SOCKET)
@@ -486,7 +495,9 @@ void HistoryConnectProc(int MenuCmd)
486495 DispTransferType();
487496
488497 DisableUserOpe();
489- CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);
498+ // 暗号化通信対応
499+// CmdCtrlSocket = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);
500+ CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security);
490501 TrnCtrlSocket = CmdCtrlSocket;
491502
492503 if(CmdCtrlSocket != INVALID_SOCKET)
@@ -959,6 +970,8 @@ int ReConnectTrnSkt(SOCKET *Skt)
959970 {
960971 // char Path[FMAX_PATH+1];
961972 int Sts;
973+ // 暗号化通信対応
974+ HOSTDATA HostData;
962975
963976 Sts = FFFTP_FAIL;
964977
@@ -969,7 +982,18 @@ int ReConnectTrnSkt(SOCKET *Skt)
969982 if(*Skt != INVALID_SOCKET)
970983 do_closesocket(*Skt);
971984 /* 再接続 */
972- if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)
985+ // 暗号化通信対応
986+ HostData = CurHost;
987+ if(HostData.CryptMode != CRYPT_NONE)
988+ HostData.UseNoEncryption = NO;
989+ if(HostData.CryptMode != CRYPT_FTPES)
990+ HostData.UseFTPES = NO;
991+ if(HostData.CryptMode != CRYPT_FTPIS)
992+ HostData.UseFTPIS = NO;
993+ if(HostData.CryptMode != CRYPT_SFTP)
994+ HostData.UseSFTP = NO;
995+// if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)
996+ if((*Skt = DoConnect(&HostData, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)
973997 {
974998 // AskRemoteCurDir(Path, FMAX_PATH);
975999 // DoCWD(Path, YES, YES, YES);
@@ -1007,7 +1031,9 @@ static int ReConnectSkt(SOCKET *Skt)
10071031 if(*Skt != INVALID_SOCKET)
10081032 do_closesocket(*Skt);
10091033 /* 再接続 */
1010- if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)
1034+ // 暗号化通信対応
1035+// if((*Skt = DoConnect(CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)
1036+ if((*Skt = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security)) != INVALID_SOCKET)
10111037 {
10121038 AskRemoteCurDir(Path, FMAX_PATH);
10131039 DoCWD(Path, YES, YES, YES);
@@ -1216,7 +1242,8 @@ int AskConnecting(void)
12161242 * none Connect host → USER user(h) → PASS pass(h) → ACCT acct
12171243 *----------------------------------------------------------------------------*/
12181244
1219-static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security)
1245+// 暗号化通信対応
1246+static SOCKET DoConnectCrypt(int CryptMode, HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security)
12201247 {
12211248 int Sts;
12221249 int Flg;
@@ -1232,143 +1259,173 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port
12321259 char TmpBuf[ONELINE_BUF_SIZE];
12331260 struct linger LingerOpt;
12341261
1235- if(Fwall == YES)
1236- Fwall = FwallType;
1237- else
1238- Fwall = FWALL_NONE;
1262+ // 暗号化通信対応
1263+ ContSock = INVALID_SOCKET;
12391264
1240- TryConnect = YES;
1241- CancelFlg = NO;
1265+ if(CryptMode == CRYPT_NONE || CryptMode == CRYPT_FTPES || CryptMode == CRYPT_FTPIS)
1266+ {
1267+ if(Fwall == YES)
1268+ Fwall = FwallType;
1269+ else
1270+ Fwall = FWALL_NONE;
1271+
1272+ TryConnect = YES;
1273+ CancelFlg = NO;
12421274 #if 0
1243-// WSASetBlockingHook(BlkHookFnc);
1275+// WSASetBlockingHook(BlkHookFnc);
12441276 #endif
12451277
1246- ContSock = INVALID_SOCKET;
1278+ ContSock = INVALID_SOCKET;
12471279
1248- HostPort = Port;
1249- Tmp = Host;
1250- if(((Fwall >= FWALL_FU_FP_SITE) && (Fwall <= FWALL_OPEN)) ||
1251- (Fwall == FWALL_SIDEWINDER) ||
1252- (Fwall == FWALL_FU_FP))
1253- {
1254- Tmp = FwallHost;
1255- Port = FwallPort;
1256- }
1280+ HostPort = Port;
1281+ Tmp = Host;
1282+ if(((Fwall >= FWALL_FU_FP_SITE) && (Fwall <= FWALL_OPEN)) ||
1283+ (Fwall == FWALL_SIDEWINDER) ||
1284+ (Fwall == FWALL_FU_FP))
1285+ {
1286+ Tmp = FwallHost;
1287+ Port = FwallPort;
1288+ }
12571289
1258- if(strlen(Tmp) != 0)
1259- {
1260- if((ContSock = connectsock(Tmp, Port, "", &CancelFlg)) != INVALID_SOCKET)
1290+ if(strlen(Tmp) != 0)
12611291 {
1262- // バッファを無効
1292+ if((ContSock = connectsock(Tmp, Port, "", &CancelFlg)) != INVALID_SOCKET)
1293+ {
1294+ // バッファを無効
12631295 #ifdef DISABLE_CONTROL_NETWORK_BUFFERS
1264- int BufferSize = 0;
1265- setsockopt(ContSock, SOL_SOCKET, SO_SNDBUF, (char*)&BufferSize, sizeof(int));
1266- setsockopt(ContSock, SOL_SOCKET, SO_RCVBUF, (char*)&BufferSize, sizeof(int));
1296+ int BufferSize = 0;
1297+ setsockopt(ContSock, SOL_SOCKET, SO_SNDBUF, (char*)&BufferSize, sizeof(int));
1298+ setsockopt(ContSock, SOL_SOCKET, SO_RCVBUF, (char*)&BufferSize, sizeof(int));
12671299 #endif
1268- while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)
1269- ;
1300+ // FTPIS対応
1301+// while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)
1302+// ;
1303+ if(CryptMode == CRYPT_FTPIS)
1304+ {
1305+ if(AttachSSL(ContSock))
1306+ {
1307+ while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)
1308+ ;
1309+ if((Sts = command(ContSock, Reply, &CancelFlg, "PBSZ 0")) == 200)
1310+ {
1311+ if((Sts = command(ContSock, Reply, &CancelFlg, "PROT P")) == 200)
1312+ {
1313+ }
1314+ else
1315+ Sts = FTP_ERROR;
1316+ }
1317+ else
1318+ Sts = FTP_ERROR;
1319+ }
1320+ else
1321+ Sts = FTP_ERROR;
1322+ }
1323+ else
1324+ {
1325+ while((Sts = ReadReplyMessage(ContSock, Buf, 1024, &CancelFlg, TmpBuf) / 100) == FTP_PRELIM)
1326+ ;
1327+ }
12701328
1271- if(Sts == FTP_COMPLETE)
1272- {
1273- Flg = 1;
1274- if(setsockopt(ContSock, SOL_SOCKET, SO_OOBINLINE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
1275- ReportWSError("setsockopt", WSAGetLastError());
1276- // データ転送用ソケットのTCP遅延転送が無効されているので念のため
1277- if(setsockopt(ContSock, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
1278- ReportWSError("setsockopt", WSAGetLastError());
1329+ if(Sts == FTP_COMPLETE)
1330+ {
1331+ Flg = 1;
1332+ if(setsockopt(ContSock, SOL_SOCKET, SO_OOBINLINE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
1333+ ReportWSError("setsockopt", WSAGetLastError());
1334+ // データ転送用ソケットのTCP遅延転送が無効されているので念のため
1335+ if(setsockopt(ContSock, IPPROTO_TCP, TCP_NODELAY, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
1336+ ReportWSError("setsockopt", WSAGetLastError());
12791337 //#pragma aaa
1280- Flg = 1;
1281- if(setsockopt(ContSock, SOL_SOCKET, SO_KEEPALIVE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
1282- ReportWSError("setsockopt", WSAGetLastError());
1283- LingerOpt.l_onoff = 1;
1284- LingerOpt.l_linger = 90;
1285- if(setsockopt(ContSock, SOL_SOCKET, SO_LINGER, (LPSTR)&LingerOpt, sizeof(LingerOpt)) == SOCKET_ERROR)
1286- ReportWSError("setsockopt", WSAGetLastError());
1338+ Flg = 1;
1339+ if(setsockopt(ContSock, SOL_SOCKET, SO_KEEPALIVE, (LPSTR)&Flg, sizeof(Flg)) == SOCKET_ERROR)
1340+ ReportWSError("setsockopt", WSAGetLastError());
1341+ LingerOpt.l_onoff = 1;
1342+ LingerOpt.l_linger = 90;
1343+ if(setsockopt(ContSock, SOL_SOCKET, SO_LINGER, (LPSTR)&LingerOpt, sizeof(LingerOpt)) == SOCKET_ERROR)
1344+ ReportWSError("setsockopt", WSAGetLastError());
12871345 ///////
12881346
12891347
1290- /*===== 認証を行なう =====*/
1348+ /*===== 認証を行なう =====*/
12911349
1292- Sts = FTP_COMPLETE;
1293- if((Fwall == FWALL_FU_FP_SITE) ||
1294- (Fwall == FWALL_FU_FP_USER) ||
1295- (Fwall == FWALL_FU_FP))
1296- {
1297- if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", FwallUser) / 100) == FTP_CONTINUE)
1350+ Sts = FTP_COMPLETE;
1351+ if((Fwall == FWALL_FU_FP_SITE) ||
1352+ (Fwall == FWALL_FU_FP_USER) ||
1353+ (Fwall == FWALL_FU_FP))
12981354 {
1299- CheckOneTimePassword(FwallPass, Reply, FwallSecurity);
1300- Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;
1355+ if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", FwallUser) / 100) == FTP_CONTINUE)
1356+ {
1357+ CheckOneTimePassword(FwallPass, Reply, FwallSecurity);
1358+ Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;
1359+ }
13011360 }
1302- }
1303- else if(Fwall == FWALL_SIDEWINDER)
1304- {
1305- Sts = command(ContSock, Reply, &CancelFlg, "USER %s:%s%c%s", FwallUser, FwallPass, FwallDelimiter, Host) / 100;
1306- }
1307- if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))
1308- {
1309- SetTaskMsg(MSGJPN006);
1310- DoClose(ContSock);
1311- ContSock = INVALID_SOCKET;
1312- }
1313- else
1314- {
1315- if((Fwall == FWALL_FU_FP_SITE) || (Fwall == FWALL_OPEN))
1361+ else if(Fwall == FWALL_SIDEWINDER)
13161362 {
1317- Flg = 0;
1318- if(Fwall == FWALL_OPEN)
1319- Flg = 2;
1320- if(FwallLower == YES)
1321- Flg++;
1322-
1323- if(HostPort == PORT_NOR)
1324- Sts = command(ContSock, NULL, &CancelFlg, "%s %s", SiteTbl[Flg], Host) / 100;
1325- else
1326- Sts = command(ContSock, NULL, &CancelFlg, "%s %s %d", SiteTbl[Flg], Host, HostPort) / 100;
1363+ Sts = command(ContSock, Reply, &CancelFlg, "USER %s:%s%c%s", FwallUser, FwallPass, FwallDelimiter, Host) / 100;
13271364 }
1328-
13291365 if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))
13301366 {
1331- SetTaskMsg(MSGJPN007, Host);
1367+ SetTaskMsg(MSGJPN006);
13321368 DoClose(ContSock);
13331369 ContSock = INVALID_SOCKET;
13341370 }
13351371 else
13361372 {
1337- Anony = NO;
1338- if((strlen(User) != 0) ||
1339- (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))
1373+ if((Fwall == FWALL_FU_FP_SITE) || (Fwall == FWALL_OPEN))
13401374 {
1341- if(Anony == YES)
1342- {
1343- strcpy(User, "anonymous");
1344- strcpy(Pass, UserMailAdrs);
1345- }
1375+ Flg = 0;
1376+ if(Fwall == FWALL_OPEN)
1377+ Flg = 2;
1378+ if(FwallLower == YES)
1379+ Flg++;
1380+
1381+ if(HostPort == PORT_NOR)
1382+ Sts = command(ContSock, NULL, &CancelFlg, "%s %s", SiteTbl[Flg], Host) / 100;
1383+ else
1384+ Sts = command(ContSock, NULL, &CancelFlg, "%s %s %d", SiteTbl[Flg], Host, HostPort) / 100;
1385+ }
13461386
1347- if((Fwall == FWALL_FU_FP_USER) || (Fwall == FWALL_USER))
1387+ if((Sts != FTP_COMPLETE) && (Sts != FTP_CONTINUE))
1388+ {
1389+ SetTaskMsg(MSGJPN007, Host);
1390+ DoClose(ContSock);
1391+ ContSock = INVALID_SOCKET;
1392+ }
1393+ else
1394+ {
1395+ Anony = NO;
1396+ if((strlen(User) != 0) ||
1397+ (InputDialogBox(username_dlg, GetMainHwnd(), NULL, User, USER_NAME_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))
13481398 {
1349- if(HostPort == PORT_NOR)
1350- sprintf(Buf, "%s%c%s", User, FwallDelimiter, Host);
1399+ if(Anony == YES)
1400+ {
1401+ strcpy(User, "anonymous");
1402+ strcpy(Pass, UserMailAdrs);
1403+ }
1404+
1405+ if((Fwall == FWALL_FU_FP_USER) || (Fwall == FWALL_USER))
1406+ {
1407+ if(HostPort == PORT_NOR)
1408+ sprintf(Buf, "%s%c%s", User, FwallDelimiter, Host);
1409+ else
1410+ sprintf(Buf, "%s%c%s %d", User, FwallDelimiter, Host, HostPort);
1411+ }
13511412 else
1352- sprintf(Buf, "%s%c%s %d", User, FwallDelimiter, Host, HostPort);
1353- }
1354- else
1355- strcpy(Buf, User);
1413+ strcpy(Buf, User);
13561414
1357- // FTPES対応
1358- // 2回以上呼ばれる事があるため既にFTPESで接続していても再確認
1359- if(CurHost.CryptMode == CRYPT_NONE || CurHost.CryptMode == CRYPT_FTPES)
1360- {
1361- if(IsOpenSSLLoaded() && CurHost.UseFTPES == YES && (Sts = command(ContSock, Reply, &CancelFlg, "AUTH TLS")) == 234)
1415+ // FTPES対応
1416+ if(CryptMode == CRYPT_FTPES)
13621417 {
1363- // SSLに切り替え
1364- SetTaskMsg(MSGJPN315);
1365- CurHost.CryptMode = CRYPT_FTPES;
1366- if(AttachSSL(ContSock))
1418+ if(IsOpenSSLLoaded() && (Sts = command(ContSock, Reply, &CancelFlg, "AUTH TLS")) == 234)
13671419 {
1368- if((Sts = command(ContSock, Reply, &CancelFlg, "PBSZ 0")) == 200)
1420+ if(AttachSSL(ContSock))
13691421 {
1370- if((Sts = command(ContSock, Reply, &CancelFlg, "PROT P")) == 200)
1422+ if((Sts = command(ContSock, Reply, &CancelFlg, "PBSZ 0")) == 200)
13711423 {
1424+ if((Sts = command(ContSock, Reply, &CancelFlg, "PROT P")) == 200)
1425+ {
1426+ }
1427+ else
1428+ Sts = FTP_ERROR;
13721429 }
13731430 else
13741431 Sts = FTP_ERROR;
@@ -1379,129 +1436,160 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port
13791436 else
13801437 Sts = FTP_ERROR;
13811438 }
1382- else
1383- {
1384- // 暗号化なし
1385- CurHost.CryptMode = CRYPT_NONE;
1386- SetTaskMsg(MSGJPN314);
1387- }
1388- }
13891439
1390- ReInPass = NO;
1391- do
1392- {
1393- Continue = NO;
1394- if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", Buf) / 100) == FTP_CONTINUE)
1440+ ReInPass = NO;
1441+ do
13951442 {
1396- if((strlen(Pass) != 0) ||
1397- (InputDialogBox(passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))
1443+ // FTPES対応
1444+ if(Sts == FTP_ERROR)
1445+ break;
1446+ Continue = NO;
1447+ if((Sts = command(ContSock, Reply, &CancelFlg, "USER %s", Buf) / 100) == FTP_CONTINUE)
13981448 {
1399- CheckOneTimePassword(Pass, Reply, Security);
1449+ if((strlen(Pass) != 0) ||
1450+ (InputDialogBox(passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))
1451+ {
1452+ CheckOneTimePassword(Pass, Reply, Security);
14001453
1401- /* パスワードがスペース1個の時はパスワードの実体なしとする */
1402- if(strcmp(Reply, " ") == 0)
1403- strcpy(Reply, "");
1454+ /* パスワードがスペース1個の時はパスワードの実体なしとする */
1455+ if(strcmp(Reply, " ") == 0)
1456+ strcpy(Reply, "");
14041457
1405- Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;
1406- if(Sts == FTP_ERROR)
1407- {
1408- strcpy(Pass, "");
1409- if(InputDialogBox(re_passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)
1410- Continue = YES;
1411- else
1412- DoPrintf("No password specified.");
1413- ReInPass = YES;
1414- }
1415- else if(Sts == FTP_CONTINUE)
1416- {
1417- if((strlen(Acct) != 0) ||
1418- (InputDialogBox(account_dlg, GetMainHwnd(), NULL, Acct, ACCOUNT_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))
1458+ Sts = command(ContSock, NULL, &CancelFlg, "PASS %s", Reply) / 100;
1459+ if(Sts == FTP_ERROR)
14191460 {
1420- Sts = command(ContSock, NULL, &CancelFlg, "ACCT %s", Acct) / 100;
1461+ strcpy(Pass, "");
1462+ if(InputDialogBox(re_passwd_dlg, GetMainHwnd(), NULL, Pass, PASSWORD_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES)
1463+ Continue = YES;
1464+ else
1465+ DoPrintf("No password specified.");
1466+ ReInPass = YES;
1467+ }
1468+ else if(Sts == FTP_CONTINUE)
1469+ {
1470+ if((strlen(Acct) != 0) ||
1471+ (InputDialogBox(account_dlg, GetMainHwnd(), NULL, Acct, ACCOUNT_LEN+1, &Anony, IDH_HELP_TOPIC_0000001) == YES))
1472+ {
1473+ Sts = command(ContSock, NULL, &CancelFlg, "ACCT %s", Acct) / 100;
1474+ }
1475+ else
1476+ DoPrintf("No account specified");
14211477 }
1422- else
1423- DoPrintf("No account specified");
14241478 }
1425- }
1426- else
1427- {
1428- Sts = FTP_ERROR;
1429- DoPrintf("No password specified.");
1479+ else
1480+ {
1481+ Sts = FTP_ERROR;
1482+ DoPrintf("No password specified.");
1483+ }
14301484 }
14311485 }
1486+ while(Continue == YES);
1487+ }
1488+ else
1489+ {
1490+ Sts = FTP_ERROR;
1491+ DoPrintf("No user name specified");
14321492 }
1433- while(Continue == YES);
1434- }
1435- else
1436- {
1437- Sts = FTP_ERROR;
1438- DoPrintf("No user name specified");
1439- }
14401493
1441- if(Sts != FTP_COMPLETE)
1442- {
1443- SetTaskMsg(MSGJPN008, Host);
1444- DoClose(ContSock);
1445- ContSock = INVALID_SOCKET;
1446- }
1447- else if((SavePass == YES) && (ReInPass == YES))
1448- {
1449- if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savepass_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)
1450- SetHostPassword(AskCurrentHost(), Pass);
1494+ if(Sts != FTP_COMPLETE)
1495+ {
1496+ SetTaskMsg(MSGJPN008, Host);
1497+ DoClose(ContSock);
1498+ ContSock = INVALID_SOCKET;
1499+ }
1500+ else if((SavePass == YES) && (ReInPass == YES))
1501+ {
1502+ if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(savepass_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)
1503+ SetHostPassword(AskCurrentHost(), Pass);
1504+ }
14511505 }
14521506 }
14531507 }
1454- }
1455- else
1456- {
1508+ else
1509+ {
14571510 //#pragma aaa
1458- SetTaskMsg(MSGJPN009/*"接続できません(1) %x", ContSock*/);
1459- DoClose(ContSock);
1460- ContSock = INVALID_SOCKET;
1511+ SetTaskMsg(MSGJPN009/*"接続できません(1) %x", ContSock*/);
1512+ DoClose(ContSock);
1513+ ContSock = INVALID_SOCKET;
1514+ }
14611515 }
14621516 }
1463- }
1464- else
1465- {
1466-
1467- if(((Fwall >= FWALL_FU_FP_SITE) && (Fwall <= FWALL_OPEN)) ||
1468- (Fwall == FWALL_FU_FP))
1469- SetTaskMsg(MSGJPN010);
14701517 else
1471- SetTaskMsg(MSGJPN011);
1472- }
1518+ {
1519+
1520+ if(((Fwall >= FWALL_FU_FP_SITE) && (Fwall <= FWALL_OPEN)) ||
1521+ (Fwall == FWALL_FU_FP))
1522+ SetTaskMsg(MSGJPN010);
1523+ else
1524+ SetTaskMsg(MSGJPN011);
1525+ }
14731526
14741527 #if 0
1475-// WSAUnhookBlockingHook();
1528+// WSAUnhookBlockingHook();
14761529 #endif
1477- TryConnect = NO;
1530+ TryConnect = NO;
14781531
1479- // FEAT対応
1480- // ホストの機能を確認
1481- if(ContSock != INVALID_SOCKET)
1482- {
1483- if((Sts = command(ContSock, Reply, &CancelFlg, "FEAT")) == 211)
1532+ // FEAT対応
1533+ // ホストの機能を確認
1534+ if(ContSock != INVALID_SOCKET)
14841535 {
1485- // 改行文字はReadReplyMessageで消去されるため区切り文字に空白を使用
1536+ if((Sts = command(ContSock, Reply, &CancelFlg, "FEAT")) == 211)
1537+ {
1538+ // 改行文字はReadReplyMessageで消去されるため区切り文字に空白を使用
1539+ // UTF-8対応
1540+ if(strstr(Reply, " UTF8 "))
1541+ HostData->Feature |= FEATURE_UTF8;
1542+ // MLST対応
1543+ if(strstr(Reply, " MLST ") || strstr(Reply, " MLSD "))
1544+ HostData->Feature |= FEATURE_MLSD;
1545+ }
14861546 // UTF-8対応
1487- if(strstr(Reply, " UTF8 "))
1488- CurHost.Feature |= FEATURE_UTF8;
1489- // MLST対応
1490- if(strstr(Reply, " MLST ") || strstr(Reply, " MLSD "))
1491- CurHost.Feature |= FEATURE_MLSD;
1492- }
1493- // UTF-8対応
1494- if(CurHost.NameKanjiCode == KANJI_AUTO && (CurHost.Feature & FEATURE_UTF8))
1495- {
1496- if((Sts = command(ContSock, Reply, &CancelFlg, "OPTS UTF8 ON")) == 200)
1547+ if(HostData->NameKanjiCode == KANJI_AUTO && (HostData->Feature & FEATURE_UTF8))
14971548 {
1549+ if((Sts = command(ContSock, Reply, &CancelFlg, "OPTS UTF8 ON")) == 200)
1550+ {
1551+ }
14981552 }
14991553 }
15001554 }
1555+ else if(CryptMode == CRYPT_SFTP)
1556+ {
1557+ }
15011558
15021559 return(ContSock);
15031560 }
15041561
1562+static SOCKET DoConnect(HOSTDATA* HostData, char *Host, char *User, char *Pass, char *Acct, int Port, int Fwall, int SavePass, int Security)
1563+{
1564+ SOCKET ContSock;
1565+ ContSock = INVALID_SOCKET;
1566+ if(ContSock == INVALID_SOCKET && HostData->UseSFTP == YES)
1567+ {
1568+ SetTaskMsg(MSGJPN317);
1569+ if((ContSock = DoConnectCrypt(CRYPT_SFTP, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)
1570+ HostData->CryptMode = CRYPT_SFTP;
1571+ }
1572+// if(ContSock == INVALID_SOCKET && HostData->UseFTPIS == YES)
1573+// {
1574+// SetTaskMsg(MSGJPN316);
1575+// if((ContSock = DoConnectCrypt(CRYPT_FTPIS, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)
1576+// HostData->CryptMode = CRYPT_FTPIS;
1577+// }
1578+ if(ContSock == INVALID_SOCKET && HostData->UseFTPES == YES)
1579+ {
1580+ SetTaskMsg(MSGJPN315);
1581+ if((ContSock = DoConnectCrypt(CRYPT_FTPES, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)
1582+ HostData->CryptMode = CRYPT_FTPES;
1583+ }
1584+ if(ContSock == INVALID_SOCKET && HostData->UseNoEncryption == YES)
1585+ {
1586+ SetTaskMsg(MSGJPN314);
1587+ if((ContSock = DoConnectCrypt(CRYPT_NONE, HostData, Host, User, Pass, Acct, Port, Fwall, SavePass, Security)) != INVALID_SOCKET)
1588+ HostData->CryptMode = CRYPT_NONE;
1589+ }
1590+ return ContSock;
1591+}
1592+
15051593
15061594 /*----- ワンタイムパスワードのチェック ----------------------------------------
15071595 *
@@ -2240,6 +2328,11 @@ int AskCryptMode(void)
22402328 return(CurHost.CryptMode);
22412329 }
22422330
2331+int AskUseNoEncryption(void)
2332+{
2333+ return(CurHost.UseNoEncryption);
2334+}
2335+
22432336 int AskUseFTPES(void)
22442337 {
22452338 return(CurHost.UseFTPES);
--- a/getput.c
+++ b/getput.c
@@ -900,7 +900,6 @@ static ULONG WINAPI TransferThread(void *Dummy)
900900 // else if(strncmp(TransPacketBase->Cmd, "R-DELE", 6) == 0)
901901 else if(strncmp(Pos->Cmd, "R-DELE", 6) == 0)
902902 {
903- ReleaseMutex(hListAccMutex);
904903 // DispTransFileInfo(TransPacketBase, MSGJPN081, FALSE, YES);
905904 DispTransFileInfo(Pos, MSGJPN081, FALSE, YES);
906905
@@ -917,6 +916,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
917916 CommandProcTrn(TrnSkt, NULL, "%s%s", Pos->Cmd+2, Pos->RemoteFile);
918917 }
919918 }
919+ ReleaseMutex(hListAccMutex);
920920 }
921921 /* ディレクトリ作成(常にローカル側) */
922922 // else if(strncmp(TransPacketBase->Cmd, "L-MKD", 5) == 0)
--- a/hostman.c
+++ b/hostman.c
@@ -1312,6 +1312,7 @@ void CopyDefaultHost(HOSTDATA *Set)
13121312 strcpy(Set->DialEntry, "");
13131313 // 暗号化通信対応
13141314 Set->CryptMode = CRYPT_NONE;
1315+ Set->UseNoEncryption = YES;
13151316 Set->UseFTPES = YES;
13161317 Set->UseFTPIS = YES;
13171318 Set->UseSFTP = YES;
--- a/socket.c
+++ b/socket.c
@@ -740,10 +740,7 @@ int do_closesocket(SOCKET s)
740740
741741 // FTPS対応
742742 // Ret = closesocket(s);
743- if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
744- Ret = closesocketS(s);
745- else
746- Ret = closesocketS(s);
743+ Ret = closesocketS(s);
747744 if(Ret == SOCKET_ERROR)
748745 {
749746 Error = 0;
@@ -970,7 +967,7 @@ int do_recv(SOCKET s, char *buf, int len, int flags, int *TimeOutErr, int *Cance
970967 // FTPS対応
971968 // OpenSSLでは受信確認はFD_READが複数回受信される可能性がある
972969 // while((*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_READ_BIT) != YES))
973- while(AskCryptMode() == CRYPT_NONE && (*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_READ_BIT) != YES))
970+ while(!IsSSLAttached(s) && (*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_READ_BIT) != YES))
974971 {
975972 if(AskAsyncDone(s, &Error, FD_CLOSE_BIT) == YES)
976973 {
@@ -1003,10 +1000,7 @@ int do_recv(SOCKET s, char *buf, int len, int flags, int *TimeOutErr, int *Cance
10031000
10041001 // FTPS対応
10051002 // Ret = recv(s, buf, len, flags);
1006- if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
1007- Ret = recvS(s, buf, len, flags);
1008- else
1009- Ret = recv(s, buf, len, flags);
1003+ Ret = recvS(s, buf, len, flags);
10101004 if(Ret != SOCKET_ERROR)
10111005 break;
10121006 Error = WSAGetLastError();
@@ -1015,11 +1009,8 @@ int do_recv(SOCKET s, char *buf, int len, int flags, int *TimeOutErr, int *Cance
10151009 break;
10161010 // FTPS対応
10171011 // 受信確認をバイパスしたためここでタイムアウトの確認
1018- if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
1019- {
1020- if(BackgrndMessageProc() == YES)
1021- *CancelCheckWork = YES;
1022- }
1012+ if(BackgrndMessageProc() == YES)
1013+ *CancelCheckWork = YES;
10231014 else if(TimeOut != 0)
10241015 {
10251016 time(&ElapseTime);
@@ -1080,7 +1071,7 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int
10801071 // FTPS対応
10811072 // 送信バッファの空き確認には影響しないが念のため
10821073 // while((*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES))
1083- while(AskCryptMode() == CRYPT_NONE && (*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES))
1074+ while(!IsSSLAttached(s) && (*CancelCheckWork == NO) && (AskAsyncDone(s, &Error, FD_WRITE_BIT) != YES))
10841075 {
10851076 if(AskAsyncDone(s, &Error, FD_CLOSE_BIT) == YES)
10861077 {
@@ -1114,10 +1105,7 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int
11141105
11151106 // FTPS対応
11161107 // Ret = send(s, buf, len, flags);
1117- if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
1118- Ret = sendS(s, buf, len, flags);
1119- else
1120- Ret = send(s, buf, len, flags);
1108+ Ret = sendS(s, buf, len, flags);
11211109 if(Ret != SOCKET_ERROR)
11221110 {
11231111 #if DBG_MSG
@@ -1131,11 +1119,8 @@ int do_send(SOCKET s, const char *buf, int len, int flags, int *TimeOutErr, int
11311119 break;
11321120 // FTPS対応
11331121 // 送信バッファ確認をバイパスしたためここでタイムアウトの確認
1134- if(AskCryptMode() == CRYPT_FTPES || AskCryptMode() == CRYPT_FTPIS)
1135- {
1136- if(BackgrndMessageProc() == YES)
1137- *CancelCheckWork = YES;
1138- }
1122+ if(BackgrndMessageProc() == YES)
1123+ *CancelCheckWork = YES;
11391124 else if(TimeOut != 0)
11401125 {
11411126 time(&ElapseTime);
--- a/taskwin.c
+++ b/taskwin.c
@@ -42,7 +42,8 @@
4242 #include "common.h"
4343 #include "resource.h"
4444
45-#define TASK_BUFSIZE (16*1024)
45+// Windows 9x系をサポートしないため不要
46+//#define TASK_BUFSIZE (16*1024)
4647
4748
4849
@@ -90,7 +91,9 @@ int MakeTaskWindow(HWND hWnd, HINSTANCE hInst)
9091
9192 if(hWndTask != NULL)
9293 {
93- SendMessage(hWndTask, EM_LIMITTEXT, TASK_BUFSIZE, 0);
94+ // Windows 9x系をサポートしないため不要
95+// SendMessage(hWndTask, EM_LIMITTEXT, TASK_BUFSIZE, 0);
96+ SendMessage(hWndTask, EM_LIMITTEXT, 0x7fffffff, 0);
9497
9598 if(ListFont != NULL)
9699 SendMessage(hWndTask, WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));
@@ -177,16 +180,17 @@ void SetTaskMsg(char *szFormat, ...)
177180 Pos = SendMessage(GetTaskWnd(), WM_GETTEXTLENGTH, 0, 0);
178181
179182 /* テキストサイズのリミット値をチェック */
180- if((Pos + strlen(szBuf)) >= TASK_BUFSIZE)
181- {
182- /* リミットを越えそうなら、先頭部分を切り捨てる */
183- Pos = SendMessage(GetTaskWnd(), EM_LINEFROMCHAR, TASK_BUFSIZE/10, 0) + 1;
184- Pos = SendMessage(GetTaskWnd(), EM_LINEINDEX, Pos, 0);
185- SendMessage(GetTaskWnd(), EM_SETSEL, 0, Pos);
186- SendMessage(GetTaskWnd(), EM_REPLACESEL, FALSE, (LPARAM)"");
187-
188- Pos = SendMessage(GetTaskWnd(), WM_GETTEXTLENGTH, 0, 0);
189- }
183+ // Windows 9x系をサポートしないため不要
184+// if((Pos + strlen(szBuf)) >= TASK_BUFSIZE)
185+// {
186+// /* リミットを越えそうなら、先頭部分を切り捨てる */
187+// Pos = SendMessage(GetTaskWnd(), EM_LINEFROMCHAR, TASK_BUFSIZE/10, 0) + 1;
188+// Pos = SendMessage(GetTaskWnd(), EM_LINEINDEX, Pos, 0);
189+// SendMessage(GetTaskWnd(), EM_SETSEL, 0, Pos);
190+// SendMessage(GetTaskWnd(), EM_REPLACESEL, FALSE, (LPARAM)"");
191+//
192+// Pos = SendMessage(GetTaskWnd(), WM_GETTEXTLENGTH, 0, 0);
193+// }
190194
191195 SendMessage(GetTaskWnd(), EM_SETSEL, Pos, Pos);
192196 SendMessage(GetTaskWnd(), EM_REPLACESEL, FALSE, (LPARAM)szBuf);