Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e8eaee4f
Commit
e8eaee4f
authored
Oct 26, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Oct 29, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Always close the data connection before receiving a server response.
parent
e55531d6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
43 deletions
+31
-43
ftp.c
dlls/wininet/ftp.c
+6
-9
ftp.c
dlls/wininet/tests/ftp.c
+25
-34
No files found.
dlls/wininet/ftp.c
View file @
e8eaee4f
...
...
@@ -1365,6 +1365,8 @@ BOOL WINAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile,
/* Receive data */
FTP_RetrieveFileData
(
lpwfs
,
nDataSocket
,
hFile
);
closesocket
(
nDataSocket
);
nResCode
=
FTP_ReceiveResponse
(
lpwfs
,
dwContext
);
if
(
nResCode
)
{
...
...
@@ -1373,7 +1375,6 @@ BOOL WINAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile,
else
FTP_SetResponseError
(
nResCode
);
}
closesocket
(
nDataSocket
);
}
}
...
...
@@ -3008,7 +3009,7 @@ static void FTP_CloseFindNextHandle(LPWININETHANDLEHEADER hdr)
* FTP_CloseFileTransferHandle (internal)
*
* Closes the file transfer handle. This also 'cleans' the data queue of
* the 'transfer co
n
plete' message (this is a bit of a hack though :-/ )
* the 'transfer co
m
plete' message (this is a bit of a hack though :-/ )
*
*/
static
void
FTP_CloseFileTransferHandle
(
LPWININETHANDLEHEADER
hdr
)
...
...
@@ -3024,16 +3025,12 @@ static void FTP_CloseFileTransferHandle(LPWININETHANDLEHEADER hdr)
if
(
!
lpwh
->
session_deleted
)
lpwfs
->
download_in_progress
=
NULL
;
/* This just serves to flush the control socket of any spurrious lines written
to it (like '226 Transfer complete.').
Wonder what to do if the server sends us an error code though...
*/
nResCode
=
FTP_ReceiveResponse
(
lpwfs
,
lpwfs
->
hdr
.
dwContext
);
if
(
lpwh
->
nDataSocket
!=
-
1
)
closesocket
(
lpwh
->
nDataSocket
);
nResCode
=
FTP_ReceiveResponse
(
lpwfs
,
lpwfs
->
hdr
.
dwContext
);
if
(
nResCode
>
0
&&
nResCode
!=
226
)
WARN
(
"server reports failed transfer
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
lpwh
);
}
...
...
dlls/wininet/tests/ftp.c
View file @
e8eaee4f
...
...
@@ -301,16 +301,12 @@ static void test_getfile(void)
/* Zero attributes */
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_non_existing_deadbeef"
,
FALSE
,
0
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
ok
(
GetFileAttributesA
(
"should_be_non_existing_deadbeef"
)
==
INVALID_FILE_ATTRIBUTES
,
"Local file should not have been created
\n
"
);
}
DeleteFileA
(
"should_be_non_existing_deadbeef"
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_existing_non_deadbeef"
,
FALSE
,
0
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
TRUE
,
"Expected FtpGetFileA to succeed
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
GetLastError
());
ok
(
GetFileAttributesA
(
"should_be_existing_non_deadbeef"
)
!=
INVALID_FILE_ATTRIBUTES
,
"Local file should have been created
\n
"
);
DeleteFileA
(
"should_be_existing_non_deadbeef"
);
/* Illegal condition flags */
SetLastError
(
0xdeadbeef
);
...
...
@@ -326,12 +322,14 @@ static void test_getfile(void)
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"should_be_non_existing_deadbeef"
,
"should_also_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
/* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
todo_wine
ok
(
GetFileAttributesA
(
"should_also_be_non_existing_deadbeef"
)
==
INVALID_FILE_ATTRIBUTES
,
"Local file should not have been created
\n
"
);
}
DeleteFileA
(
"should_also_be_non_existing_deadbeef"
);
/* Same call as the previous but now the local file does exists. Windows just removes the file if the call fails
...
...
@@ -346,32 +344,30 @@ static void test_getfile(void)
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"should_be_non_existing_deadbeef"
,
"should_also_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
/* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
todo_wine
ok
(
GetFileAttributesA
(
"should_also_be_non_existing_deadbeef"
)
==
INVALID_FILE_ATTRIBUTES
,
"Local file should not have been created
\n
"
);
}
DeleteFileA
(
"should_also_be_non_existing_deadbeef"
);
/* This one should
fail
*/
/* This one should
succeed
*/
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_existing_non_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
TRUE
,
"Expected FtpGetFileA to fail
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
GetLastError
());
if
(
GetFileAttributesA
(
"should_be_
non_existing
_deadbeef"
)
!=
INVALID_FILE_ATTRIBUTES
)
if
(
GetFileAttributesA
(
"should_be_
existing_non
_deadbeef"
)
!=
INVALID_FILE_ATTRIBUTES
)
{
/* Should succeed as fFailIfExists is set to FALSE (meaning don't fail if local file exists) */
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
todo_wine
{
ok
(
bRet
==
TRUE
,
"Expected FtpGetFileA to succeed
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
GetLastError
());
}
/* Should fail as fFailIfExists is set to TRUE */
SetLastError
(
0xdeadbeef
);
...
...
@@ -387,7 +383,7 @@ static void test_getfile(void)
ok
(
GetLastError
()
==
ERROR_FILE_EXISTS
,
"Expected ERROR_FILE_EXISTS, got %d
\n
"
,
GetLastError
());
DeleteFileA
(
"should_be_
non_existing
_deadbeef"
);
DeleteFileA
(
"should_be_
existing_non
_deadbeef"
);
}
InternetCloseHandle
(
hFtp
);
...
...
@@ -478,13 +474,8 @@ static void test_openfile(void)
SetLastError
(
0xdeadbeef
);
hOpenFile
=
FtpOpenFileA
(
hFtp
,
"welcome.msg"
,
GENERIC_READ
,
FTP_TRANSFER_TYPE_ASCII
,
0
);
todo_wine
{
ok
(
hOpenFile
==
NULL
,
"Expected FtpOpenFileA to fail
\n
"
);
/* For some strange/unknown reason, win98 returns ERROR_FILE_NOT_FOUND */
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
||
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_INTERNET_EXTENDED_ERROR or ERROR_FILE_NOT_FOUND (win98), got %d
\n
"
,
GetLastError
());
}
ok
(
hOpenFile
!=
NULL
,
"Expected FtpOpenFileA to succeed
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %u
\n
"
,
GetLastError
());
if
(
hOpenFile
)
{
...
...
@@ -840,14 +831,14 @@ static void test_multiple(void)
}
/* A correct call */
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
DeleteFileA
(
"should_be_non_existing_deadbeef"
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_existing_non_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
,
"Expected FtpGetFileA to succeed
\n
"
);
DeleteFileA
(
"should_be_existing_non_deadbeef"
);
SetLastError
(
0xdeadbeef
);
hOpenFile
=
FtpOpenFileA
(
hFtp
,
"welcome.msg"
,
GENERIC_READ
,
FTP_TRANSFER_TYPE_ASCII
,
0
);
ok
(
hOpenFile
==
NULL
,
"Expected FtpOpenFileA to fail
\n
"
);
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
||
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_INTERNET_EXTENDED_ERROR or ERROR_FILE_NOT_FOUND (win98), got %d
\n
"
,
GetLastError
());
ok
(
hOpenFile
!=
NULL
,
"Expected FtpOpenFileA to succeed
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %u
\n
"
,
GetLastError
());
InternetCloseHandle
(
hOpenFile
);
InternetCloseHandle
(
hFtp
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment